import type { LogContext } from '@rocicorp/logger';
import type postgres from 'postgres';
import { AbortError } from '../../../../../shared/src/abort-error.ts';
import { type PostgresDB } from '../../../types/pg.ts';
import { type ShardID } from '../../../types/shards.ts';
import type { BackfillID, Change, TableMetadata } from '../../change-source/protocol/current/data.ts';
import type { SubscriptionState } from '../../replicator/schema/replication-state.ts';
export declare const PG_SCHEMA = "cdc";
export type ChangeLogEntry = {
    watermark: string;
    change: Change;
};
/**
 * Tracks the watermark from which to resume the change stream and the
 * current owner (task ID) acting as the single writer to the changeLog.
 */
export type ReplicationState = {
    lastWatermark: string;
    owner: string | null;
    ownerAddress: string | null;
};
export declare function createReplicationStateTable(shard: ShardID): string;
export declare function discoverChangeStreamerAddress(shard: ShardID, sql: PostgresDB): Promise<string | null>;
/**
 * This mirrors the analogously named table in the SQLite replica
 * (`services/replicator/schema/replication-state.ts`), and is used
 * to detect when the replica has been reset and is no longer compatible
 * with the current ChangeLog.
 */
export type ReplicationConfig = {
    replicaVersion: string;
    publications: readonly string[];
};
export declare function createBackfillTables(shard: ShardID): string;
export type TableMetadataRow = {
    schema: string;
    table: string;
    metadata: TableMetadata;
};
export type BackfillingColumn = {
    schema: string;
    table: string;
    column: string;
    backfill: BackfillID;
};
export declare function setupCDCTables(lc: LogContext, db: postgres.TransactionSql, shard: ShardID): Promise<void>;
export declare function markResetRequired(sql: PostgresDB, shard: ShardID): Promise<void>;
export declare function ensureReplicationConfig(lc: LogContext, db: PostgresDB, subscriptionState: Pick<SubscriptionState, 'publications' | 'replicaVersion' | 'watermark'>, shard: ShardID, autoReset: boolean): Promise<void>;
export declare class AutoResetSignal extends AbortError {
    readonly name = "AutoResetSignal";
}
//# sourceMappingURL=tables.d.ts.map