SyncTableInput
SyncTableInput<
TName,TColumns,TOmittedColumns> =object
Defined in: packages/contracts/src/registry.ts:371
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:414
Backfill conflict policy (ADR-0045). Default "insert" — the initial load assumes an empty
table (fresh subscription or post-must-refetch re-snapshot) and takes the fast path, COPY or a plain
multi-row INSERT, neither of which can express ON CONFLICT. Set "upsert" only when this table
legitimately receives locally-DERIVED provisional rows a backfill could land on top of — e.g. a local
trigger on another synced table inserts a provisional row here, and the server independently creates
the same row (23505). Steady-state changes are unaffected: the engine emits upsert, so they apply
as INSERT … ON CONFLICT (pk) DO UPDATE for every table. See SyncTableEntry.applyMode.
clientProjection?
Section titled “clientProjection?”
optionalclientProjection?:SyncTableInputProjection<TColumns,TOmittedColumns>
Defined in: packages/contracts/src/registry.ts:422
conflictPolicy?
Section titled “conflictPolicy?”
optionalconflictPolicy?:ConflictPolicy
Defined in: packages/contracts/src/registry.ts:431
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:437
Bind this table into a consistency group (ADR-0009 decision 2): grouped tables sync as one set of streams 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:385
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:425
makeColumns
Section titled “makeColumns”makeColumns: () =>
TColumns
Defined in: packages/contracts/src/registry.ts:377
Returns
Section titled “Returns”TColumns
optionalmode?:TableMode
Defined in: packages/contracts/src/registry.ts:389
Default
Section titled “Default”"readonly"policies?
Section titled “policies?”
optionalpolicies?:PgPolicy[]
Defined in: packages/contracts/src/registry.ts:379
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:404
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:446
Retention (ADR-0021): persistent (default) | ephemeral. See SyncTableEntry.retention.
rowClass?
Section titled “rowClass?”
optionalrowClass?:string
Defined in: packages/contracts/src/registry.ts:420
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:387
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:424
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:421
subscription?
Section titled “subscription?”
optionalsubscription?:SubscriptionTiming
Defined in: packages/contracts/src/registry.ts:442
Subscription timing (ADR-0021): eager (default) | lazy. See
SyncTableEntry.subscription.
tableName
Section titled “tableName”tableName:
TName
Defined in: packages/contracts/src/registry.ts:376
writeMode?
Section titled “writeMode?”
optionalwriteMode?:WriteMode
Defined in: packages/contracts/src/registry.ts:450
Write-mode (ADR-0022): optimistic (default) | pessimistic. See SyncTableEntry.writeMode.