SyncTableInput
SyncTableInput<
TName,TColumns,TOmittedColumns> =object
Defined in: packages/contracts/src/registry.ts:332
Input for defineSyncTable. Supply tableName + makeColumns — the Drizzle table
(and, for readwrite mode, the read-model view) are created internally.
Access the built objects via .table and .view on the returned entry.
Type Parameters
Section titled “Type Parameters”TName extends string
TColumns
Section titled “TColumns”TColumns extends Record<string, ColumnBuilderBase>
TOmittedColumns
Section titled “TOmittedColumns”TOmittedColumns extends readonly ColumnKeys<TColumns>[] = []
Properties
Section titled “Properties”applyMode?
Section titled “applyMode?”
optionalapplyMode?:"insert"|"upsert"
Defined in: packages/contracts/src/registry.ts:376
CDC insert-apply policy (ADR-0045). Default "insert" — a CDC insert is a plain INSERT, so a
genuine PK collision must surface (the ADR-0014 collision-surfacing invariant; a synced cache table
is server-authoritative and a duplicate insert is a real bug). Set "upsert" only when this
table legitimately receives locally-DERIVED provisional rows — e.g. a local trigger on another
synced table inserts a provisional row here, and the server independently creates the same row so
its CDC insert would collide (23505). With "upsert", server CDC inserts are applied idempotently
as INSERT … ON CONFLICT (pk) DO UPDATE; the authoritative server row overwrites the provisional
local row. Declare the exception here, where it lives — do not weaken the invariant repo-wide.
clientProjection?
Section titled “clientProjection?”
optionalclientProjection?:SyncTableInputProjection<TColumns,TOmittedColumns>
Defined in: packages/contracts/src/registry.ts:384
conflictPolicy?
Section titled “conflictPolicy?”
optionalconflictPolicy?:ConflictPolicy
Defined in: packages/contracts/src/registry.ts:393
Conflict policy (ADR-0015): what happens to a stale write on this table. Required for writable
tables — defineSyncTable/defineSyncRegistry reject a writable table without one. See
ConflictPolicy.
consistencyGroup?
Section titled “consistencyGroup?”
optionalconsistencyGroup?:string
Defined in: packages/contracts/src/registry.ts:399
Bind this table into a consistency group (ADR-0009 decision 2): grouped tables sync on one
MultiShapeStream and commit atomically. Omit for the default singleton group. See
SyncTableEntry.consistencyGroup.
extras?
Section titled “extras?”
optionalextras?: (self) =>PgTableExtraConfigValue[]
Defined in: packages/contracts/src/registry.ts:346
Extra constraints or indexes on the server-side Postgres table (unique, index, etc.).
Receives the built column map — same signature as pgTable’s third argument.
Not applied to localTable.
Parameters
Section titled “Parameters”PgBuildExtraConfigColumns<TColumns>
Returns
Section titled “Returns”PgTableExtraConfigValue[]
governance?
Section titled “governance?”
optionalgovernance?:SyncTableInputGovernance<TColumns>
Defined in: packages/contracts/src/registry.ts:387
makeColumns
Section titled “makeColumns”makeColumns: () =>
TColumns
Defined in: packages/contracts/src/registry.ts:338
Returns
Section titled “Returns”TColumns
optionalmode?:TableMode
Defined in: packages/contracts/src/registry.ts:350
Default
Section titled “Default”"readonly"policies?
Section titled “policies?”
optionalpolicies?:PgPolicy[]
Defined in: packages/contracts/src/registry.ts:340
RLS policies (or other table extras) attached to the Postgres table.
primaryKey?
Section titled “primaryKey?”
optionalprimaryKey?:string[] | {columns:string[];name:string; }
Defined in: packages/contracts/src/registry.ts:365
THE primary key of the server table — the single source of truth for its physical
PRIMARY KEY constraint. defineSyncTable emits it as the constraint, named
`${tableName}_pkey` (matching Postgres’s inline-PK default, so existing consumer
databases see no rename churn) unless the object form overrides name.
Defaults to ["id"]. Use an array with multiple entries for composite keys, or the object
form { name, columns } to name the constraint.
A single-column key MAY equivalently be declared via the column’s own .primaryKey()
(idiomatic drizzle); it must match this spec, and emission is then skipped because the
column already carries the constraint. A table-level primaryKey(...) in extras/policies
is REJECTED — declare the key here instead.
retention?
Section titled “retention?”
optionalretention?:Retention
Defined in: packages/contracts/src/registry.ts:408
Retention (ADR-0021): persistent (default) | ephemeral. See SyncTableEntry.retention.
rowClass?
Section titled “rowClass?”
optionalrowClass?:string
Defined in: packages/contracts/src/registry.ts:382
Consumer-defined row classification (ADR-0052) — see SyncTableEntry.rowClass. Required (and checked against the declared set) when the registry declares SyncRegistryDefinition.rowClasses; unconstrained otherwise.
schema?
Section titled “schema?”
optionalschema?:PgSchemaType
Defined in: packages/contracts/src/registry.ts:348
Place the table in this schema (e.g. for perf-lab schemed tables).
serverProjection?
Section titled “serverProjection?”
optionalserverProjection?:ServerProjectionSpec
Defined in: packages/contracts/src/registry.ts:386
Server-side response-path projection (e.g. rowTransform). Server authority, not client shape.
shape?
Section titled “shape?”
optionalshape?:ShapeSpecInputFor<TColumns>
Defined in: packages/contracts/src/registry.ts:383
subscription?
Section titled “subscription?”
optionalsubscription?:SubscriptionTiming
Defined in: packages/contracts/src/registry.ts:404
Subscription timing (ADR-0021): eager (default) | lazy. See
SyncTableEntry.subscription.
tableName
Section titled “tableName”tableName:
TName
Defined in: packages/contracts/src/registry.ts:337
writeMode?
Section titled “writeMode?”
optionalwriteMode?:WriteMode
Defined in: packages/contracts/src/registry.ts:412
Write-mode (ADR-0022): optimistic (default) | pessimistic. See SyncTableEntry.writeMode.