Skip to content

Commit e79f481

Browse files
committed
docs(spec): regenerate the migration reference page for DataMigrationFlag
The generated `content/docs/references/system/migration.mdx` is derived from `migration.zod.ts` and CI checks the two agree — adding the schema without regenerating left them out of sync. The page's intro is the file's first JSDoc block, and `migration.zod.ts` had none, so the regenerate lifted the `DATA_MIGRATION_FLAG_OBJECT` constant's TSDoc into that slot. Given the module now carries both kinds of migration, a real file-level docblock is what the page wants anyway: it says why the two are separate — a ChangeSet reshapes the database from metadata, while whether a data migration has run is a fact about one deployment's rows that no release can assert. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9uWWyKq6pNPQthwCXL8ma
1 parent 5568026 commit e79f481

2 files changed

Lines changed: 59 additions & 2 deletions

File tree

content/docs/references/system/migration.mdx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@ description: Migration protocol schemas
55

66
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
77

8+
Migration protocol — the two kinds of migration, kept apart on purpose.
9+
10+
A **schema migration** (`ChangeSet` + its atomic operations) reshapes the
11+
12+
physical database to match metadata: add a field, change a type, create an
13+
14+
object, run SQL. It is derivable from the metadata and applied by
15+
16+
`os migrate plan` / `os migrate apply`.
17+
18+
A **data migration** rewrites the rows themselves, and whether it is done is
19+
20+
a property of ONE DEPLOYMENT's database rather than of the installed code
21+
22+
version — so it cannot be expressed as a ChangeSet, and its completion cannot
23+
24+
be inferred from a release. `DataMigrationFlag` is the per-deployment record
25+
26+
that one ran here and its self-check passed; consumers that would act
27+
28+
irreversibly on migrated data gate on the flag instead of the version.
29+
830
<Callout type="info">
931
**Source:** `packages/spec/src/system/migration.zod.ts`
1032
</Callout>
1133

1234
## TypeScript Usage
1335

1436
```typescript
15-
import { AddFieldOperation, ChangeSet, CreateObjectOperation, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, MigrationOperation, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
16-
import type { AddFieldOperation, ChangeSet, CreateObjectOperation, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, MigrationOperation, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
37+
import { AddFieldOperation, ChangeSet, CreateObjectOperation, DataMigrationFlag, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, MigrationOperation, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
38+
import type { AddFieldOperation, ChangeSet, CreateObjectOperation, DataMigrationFlag, DeleteObjectOperation, ExecuteSqlOperation, MigrationDependency, MigrationOperation, ModifyFieldOperation, RemoveFieldOperation, RenameObjectOperation } from '@objectstack/spec/system';
1739

1840
// Validate data
1941
const result = AddFieldOperation.parse(data);
@@ -69,6 +91,25 @@ Create a new object
6991
| **object** | `{ name: string; label?: string; pluralLabel?: string; description?: string; … }` || Full object definition to create |
7092

7193

94+
---
95+
96+
## DataMigrationFlag
97+
98+
Deployment-level record that a data migration ran here and its self-check passed — the evidence gate consumers read instead of the platform version
99+
100+
### Properties
101+
102+
| Property | Type | Required | Description |
103+
| :--- | :--- | :--- | :--- |
104+
| **id** | `string` || Migration id (e.g. adr-0104-file-references) — one row per data migration |
105+
| **last_run_at** | `string` || When this migration last completed a gated (apply-mode) run on this deployment |
106+
| **verified_at** | `string \| null` | optional | When the self-check last PASSED. Null/absent until it does — and cleared again by a later failing run, so a regression closes the gate |
107+
| **applied_at** | `string \| null` | optional | When the backfill last ran in apply mode (writes enabled) |
108+
| **blocking** | `integer` || Blocking discrepancies reported by the last self-check. The gate requires 0 |
109+
| **advisory** | `integer` | optional | Advisory findings from the last run (external URLs, stale owners, …) — cost storage or need a modelling decision, never block the gate |
110+
| **details** | `string` | optional | JSON-encoded counts from the last run, for diagnostics |
111+
112+
72113
---
73114

74115
## DeleteObjectOperation

packages/spec/src/system/migration.zod.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
/**
4+
* Migration protocol — the two kinds of migration, kept apart on purpose.
5+
*
6+
* A **schema migration** (`ChangeSet` + its atomic operations) reshapes the
7+
* physical database to match metadata: add a field, change a type, create an
8+
* object, run SQL. It is derivable from the metadata and applied by
9+
* `os migrate plan` / `os migrate apply`.
10+
*
11+
* A **data migration** rewrites the rows themselves, and whether it is done is
12+
* a property of ONE DEPLOYMENT's database rather than of the installed code
13+
* version — so it cannot be expressed as a ChangeSet, and its completion cannot
14+
* be inferred from a release. `DataMigrationFlag` is the per-deployment record
15+
* that one ran here and its self-check passed; consumers that would act
16+
* irreversibly on migrated data gate on the flag instead of the version.
17+
*/
18+
319
import { z } from 'zod';
420
import { FieldSchema } from '../data/field.zod';
521
import { ObjectSchema } from '../data/object.zod';

0 commit comments

Comments
 (0)