Skip to main content

Function: defineSchemaUpdate()

defineSchemaUpdate<T, S>(name, migration): SchemaUpdate<T, S>

Defined in: defineSchemaUpdate.ts:93

Define a named, reusable schema change. The callback receives a SchemaBuilder — one builder per existing model — and returns the records and unions it changed or added.

Type Parameters​

T​

T extends ModelDefs

S​

S extends ModelDefs

Parameters​

name​

string

A stable identifier for this change, used to track the migration.

migration​

(schema) => S

Returns​

SchemaUpdate<T, S>

Example​

const splitColor = defineSchemaUpdate("splitColor", schema => {
const ShapeBox = schema.ShapeBox
.addField("fillColor", Optional(String), { derivedFrom: ["color"] })
.deprecateField("color", "Use fillColor instead.")
.build();
return { ShapeBox };
});