/** * Raw DDL for Postgres v-next observability tables. * * One table per signal: * - mastra_span_events (insert-only ended spans; root spans surfaced * via partial indexes, not a separate table) * - mastra_metric_events * - mastra_log_events * - mastra_score_events * - mastra_feedback_events * - mastra_observability_discovery (cache table for discovery values) * * Physical conventions: * - timestamptz for all timestamps (millisecond precision; Postgres native) * - text + jsonb for IDs and payloads * - text[] for `tags`, jsonb for `metadataSearch` / `labels` * - Range partitioning by day on the time column (endedAt for spans, timestamp * for others). Partition key is part of every primary key, as Postgres * requires for partitioned tables. * - Root-span lookups (the `listTraces` / `getRootSpan` read surface) are * served by partial indexes on `mastra_span_events` * (`WHERE "parentSpanId" IS NULL`). This is the Postgres-idiomatic * equivalent of the ClickHouse `mastra_trace_roots` incremental MV: * selective enough to act as a projection while avoiding the trigger, * duplicate storage, and write amplification of a second table. The * partial indexes are also chunk-local on a Timescale hypertable, so the * same plan applies there. * - Retention is intentionally NOT implemented in this domain; the partition * skeleton exists so a future `mastra retention` CLI command can drop or * compress old partitions. pg_partman is detected and used when available. * - TimescaleDB is detected and create_hypertable() is called when the * extension is present. The base DDL is identical either way. */ export declare const TABLE_SPAN_EVENTS = "mastra_span_events"; export declare const TABLE_METRIC_EVENTS = "mastra_metric_events"; export declare const TABLE_LOG_EVENTS = "mastra_log_events"; export declare const TABLE_SCORE_EVENTS = "mastra_score_events"; export declare const TABLE_FEEDBACK_EVENTS = "mastra_feedback_events"; export declare const TABLE_DISCOVERY = "mastra_observability_discovery"; export declare const ALL_SIGNAL_TABLES: readonly ["mastra_span_events", "mastra_metric_events", "mastra_log_events", "mastra_score_events", "mastra_feedback_events"]; export declare const ALL_TABLE_NAMES: readonly ["mastra_span_events", "mastra_metric_events", "mastra_log_events", "mastra_score_events", "mastra_feedback_events", "mastra_observability_discovery"]; /** Maps each signal table to the column used as its partition / TTL key. */ export declare const SIGNAL_TIME_COLUMN: Record<(typeof ALL_SIGNAL_TABLES)[number], string>; /** Returns a fully-qualified, double-quoted table name. */ export declare function qualifiedTable(schema: string, table: string): string; /** Returns a parsed, quoted, schema-prefixed object name (constraint, index, etc.). */ export declare function qualifiedName(schema: string, name: string): string; /** Schema CREATE. Safe to run repeatedly before table DDL. */ export declare function schemaDDL(schema: string): string; export type TableDDLMode = 'timescale' | 'partitioned'; /** All table CREATEs in dependency-safe order. */ export declare function allTableDDL(schema: string, mode: TableDDLMode): string[]; /** * Additive column migrations for tables created by an older version of this * schema. `CREATE TABLE IF NOT EXISTS` is a no-op on an existing table, so new * columns have to be added out of band. * * `ALTER TABLE` takes an AccessExclusiveLock on the partitioned parent, so * callers must check {@link columnExistsSQL} first and only run the statement * when the column is genuinely missing. On Postgres 11+ the non-volatile * default does not rewrite the table, and the ALTER cascades to partitions. */ export declare function additiveColumns(schema: string): { table: string; column: string; ddl: string; }[]; /** Existence probe for an additive column. Params: schema, table, column. */ export declare const columnExistsSQL = "SELECT 1 FROM information_schema.columns\n WHERE table_schema = $1 AND table_name = $2 AND column_name = $3"; /** Index CREATEs. Safe to run repeatedly. */ export declare function allIndexDDL(schema: string): string[]; //# sourceMappingURL=ddl.d.ts.map