/** * Partition + extension management for the v-next Postgres observability domain. * * Three modes (auto-detected at init unless overridden by config): * * 1. TimescaleDB present → call `create_hypertable()` for each signal table. * Chunks are created automatically; we never * pre-create partitions and never call pg_partman. * * 2. pg_partman present → register each signal table as a daily-partitioned * parent and let partman maintain future partitions. * * 3. Neither extension → pre-create a rolling window of daily partitions * (yesterday + today + N future days). Future * partitions can be extended by a separate Mastra * CLI command, which is also the surface that will * implement retention cleanup. * * This module deliberately does not implement retention deletes / drops. * The goal here is to leave the schema in a shape that a follow-up * `mastra retention` command can act on without further migrations. */ import type { DbClient } from '../../../client.js'; export type PartitionMode = 'timescale' | 'partman' | 'native'; export interface PartitioningOptions { /** Override auto-detection. */ mode?: PartitionMode | 'auto'; /** * Number of future daily partitions to pre-create when running in 'native' * mode. Default 14. Has no effect in timescale or partman modes. */ futureDays?: number; /** * Whether to pre-create a partition for yesterday (covers small clock skew * and late-arriving events). Default true. */ includeYesterday?: boolean; } export declare function detectTimescale(client: DbClient): Promise; export declare function detectPartman(client: DbClient): Promise; export declare function getPartmanVersion(client: DbClient): Promise; export declare function resolveMode(client: DbClient, options?: PartitioningOptions): Promise; /** * Creates daily partition tables in [today - 1 day, today + futureDays]. * Idempotent: uses CREATE TABLE IF NOT EXISTS. */ export declare function ensureNativePartitions(client: DbClient, schema: string, options?: PartitioningOptions): Promise; /** * Lists existing daily partitions for a signal table. Used by tests and the * future `mastra retention` CLI command. */ export declare function listPartitions(client: DbClient, schema: string, table: string): Promise; /** * Calls `create_hypertable()` for each signal table. * * Postgres declarative partitioning and Timescale hypertables are mutually * exclusive, so the base DDL must have been generated with TableDDLMode * 'timescale' (no `PARTITION BY` clause). `if_not_exists` makes this * idempotent across re-inits. */ export declare function ensureTimescaleHypertables(client: DbClient, schema: string): Promise; /** * Registers each signal table with pg_partman as a daily-interval parent and * lets partman create the child partitions. * * Retention is intentionally NOT configured here — it stays opt-in via the * future Mastra CLI surface. * * Prefers the pg_partman 5.x+ declarative API (`p_type := 'range'`) and keeps * a 4.x fallback (`p_type := 'native'`) for older installs. That lets the * adapter run against current arm64-friendly images without breaking existing * 4.x deployments. */ export declare function ensurePartmanHypertables(client: DbClient, schema: string): Promise; export declare function setupPartitioning(client: DbClient, schema: string, options?: PartitioningOptions): Promise; //# sourceMappingURL=partitioning.d.ts.map