/**
 * Column metadata table for storing upstream PostgreSQL schema information.
 *
 * Previously, upstream type metadata was embedded in SQLite column type strings
 * using pipe-delimited notation (e.g., "int8|NOT_NULL|TEXT_ENUM"). This caused
 * issues with SQLite type affinity and made schema inspection difficult.
 *
 * This table stores that metadata separately, allowing SQLite columns to use
 * plain type names while preserving all necessary upstream type information.
 */
import type { Database } from '../../../../../zqlite/src/db.ts';
import type { ColumnSpec, LiteTableSpec } from '../../../db/specs.ts';
import type { BackfillID } from '../../change-source/protocol/current.ts';
/**
 * Structured column metadata, replacing the old pipe-delimited string format.
 */
export interface ColumnMetadata {
    /** PostgreSQL type name, e.g., 'int8', 'varchar', 'text[]', 'user_role' */
    upstreamType: string;
    isNotNull: boolean;
    isEnum: boolean;
    isArray: boolean;
    /** Maximum character length for varchar/char types */
    characterMaxLength?: number | null;
    isBackfilling: boolean;
}
export declare const CREATE_COLUMN_METADATA_TABLE = "\n  CREATE TABLE \"_zero.column_metadata\" (\n    table_name TEXT NOT NULL,\n    column_name TEXT NOT NULL,\n    upstream_type TEXT NOT NULL,\n    is_not_null INTEGER NOT NULL,\n    is_enum INTEGER NOT NULL,\n    is_array INTEGER NOT NULL,\n    character_max_length INTEGER,\n    backfill TEXT,\n    PRIMARY KEY (table_name, column_name)\n  );\n";
/**
 * Efficient column metadata store that prepares all statements upfront.
 * Use this class to avoid re-preparing statements on every operation.
 *
 * Access via `ColumnMetadataStore.getInstance(db)`, which returns `undefined`
 * if the metadata table doesn't exist yet.
 */
export declare class ColumnMetadataStore {
    #private;
    private constructor();
    /**
     * Gets the singleton instance of ColumnMetadataStore for the given database.
     * Returns `undefined` if the metadata table doesn't exist yet.
     */
    static getInstance(db: Database): ColumnMetadataStore | undefined;
    insert(tableName: string, columnName: string, spec: ColumnSpec, backfill?: BackfillID | undefined): void;
    update(tableName: string, oldColumnName: string, newColumnName: string, spec: ColumnSpec): void;
    clearBackfilling(tableName: string, columnName: string): void;
    deleteColumn(tableName: string, columnName: string): void;
    deleteTable(tableName: string): void;
    renameTable(oldTableName: string, newTableName: string): void;
    getColumn(tableName: string, columnName: string): ColumnMetadata | undefined;
    getTable(tableName: string): Map<string, ColumnMetadata>;
    hasTable(): boolean;
}
/**
 * Populates metadata table from existing tables that use pipe notation.
 * This is used during migration v8 to backfill the metadata table.
 */
export declare function populateFromExistingTables(db: Database, tables: LiteTableSpec[]): void;
/**
 * Converts pipe-delimited LiteTypeString to structured ColumnMetadata.
 * This is a compatibility helper for the migration period.
 */
export declare function liteTypeStringToMetadata(liteTypeString: string, characterMaxLength?: number | null): ColumnMetadata;
/**
 * Converts structured ColumnMetadata back to pipe-delimited LiteTypeString.
 * This is a compatibility helper for the migration period.
 */
export declare function metadataToLiteTypeString(metadata: ColumnMetadata): string;
/**
 * Converts PostgreSQL ColumnSpec to structured ColumnMetadata.
 * Used during replication to populate the metadata table from upstream schema.
 *
 * Uses the same logic as liteTypeString() and mapPostgresToLiteColumn() via shared helpers.
 */
export declare function pgColumnSpecToMetadata(spec: ColumnSpec): ColumnMetadata;
//# sourceMappingURL=column-metadata.d.ts.map