Migration
Migration protocol schemas
Source: packages/spec/src/system/migration.zod.ts
TypeScript Usage
import { AddFieldOperation, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
import type { AddFieldOperation, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
// Validate data
const result = AddFieldOperation.parse(data);AddFieldOperation
Add a new field to an existing object
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| objectName | string | ✅ | Target object name |
| fieldName | string | ✅ | Name of the field to add |
| field | Object | ✅ | Full field definition to add |
DeleteObjectOperation
Delete an existing object
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| objectName | string | ✅ | Name of the object to delete |
ExecuteSqlOperation
Execute a raw SQL statement
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| sql | string | ✅ | Raw SQL statement to execute |
| description | string | optional | Human-readable description of the SQL |
MigrationDependency
Dependency reference to another migration that must run first
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| migrationId | string | ✅ | ID of the migration this depends on |
| package | string | optional | Package that owns the dependency migration |
ModifyFieldOperation
Modify properties of an existing field
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| objectName | string | ✅ | Target object name |
| fieldName | string | ✅ | Name of the field to modify |
| changes | Record<string, any> | ✅ | Partial field definition updates |
RemoveFieldOperation
Remove a field from an existing object
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| objectName | string | ✅ | Target object name |
| fieldName | string | ✅ | Name of the field to remove |
RenameObjectOperation
Rename an existing object
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | string | ✅ | |
| oldName | string | ✅ | Current object name |
| newName | string | ✅ | New object name |