You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/migrations-and-drift.md
+20-13Lines changed: 20 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ There are **7 drift sources**, and the toolchain has a guard for each.
13
13
|---|---|---|
14
14
|**Code-vs-DB**| Codegen — the generated SQL DDL is emitted from the same metadata as the entity / table code. | Build time |
15
15
|**Code-vs-API-doc**| Cross-port codegen from the same metadata. | Build time |
16
-
|**DB-vs-metadata**|`meta:verify` Maven goal / `meta verify` CLI — introspects the live DB and fails the build if it has drifted from metadata. | CI on every PR |
17
-
|**Migration-vs-metadata**|`meta migrate` (TS / C#) / `meta:migrate --flyway` (Java / Kotlin) emits migrations FROM metadata diffs — they cannot drift from metadata by construction. | Build time |
16
+
|**DB-vs-metadata**|`metaverify --db` (TS CLI) — introspects the live DB and fails if it has drifted from metadata. Java/Kotlin: runtime startup validator (`MetaClassDBValidatorService`) catches generated-table drift at app startup; the removed `meta:verify` Maven goal is not available. | CI on every PR (TS); app startup (Java/Kotlin)|
17
+
|**Migration-vs-metadata**|`meta migrate` (TS / C# / Python) emits migrations FROM metadata diffs — they cannot drift from metadata by construction. Java/Kotlin schema migrations are also owned by the TS toolchain (`@metaobjectsdev/cli migrate`). | Build time |
18
18
|**Generated-edited**|`@generated` headers in emitted code + three-way merge that preserves hand-edits inside non-generated regions. | Code review |
19
19
|**Prompt-vs-payload**| FR-004 `Renderer.verify` parses `{{...}}` references in templates and checks each one exists on the payload VO. | Build time + runtime |
20
20
|**Generated-vs-runtime**| Kotlin / Java `MetadataStartupValidator` (from Spring `ApplicationReadyEvent`) re-loads metadata at startup and asserts the generated table objects match. | App startup |
@@ -57,21 +57,28 @@ configured in `metaobjects.config.ts` (typically `./migrations/<timestamp>__<slu
57
57
58
58
### Java
59
59
60
+
Schema migrations for Java projects are owned by the **TypeScript toolchain**
61
+
(`@metaobjectsdev/cli migrate`). The Java Maven plugin's `meta:migrate` goal was
62
+
removed. Java retains a dev/test runtime auto-create path via
63
+
`MetaClassDBValidatorService` (the drivers' `createTable` DDL), not a migration
64
+
engine.
65
+
66
+
Use the TS CLI against the same database the Java service connects to:
67
+
60
68
```bash
61
-
mvn meta:migrate # writes a numbered SQL file
62
-
mvn meta:migrate -Dflyway=true # writes V<N>__<slug>.sql under src/main/resources/db/migration/
Flyway mode auto-versions by scanning existing migrations.
66
-
67
73
### Kotlin
68
74
69
-
Uses the Java Maven plugin's `meta:migrate` mojo (Kotlin codegen tier rides on the
70
-
same plugin). Flyway prefix + directory are configurable via the plugin's
71
-
`<flywayDir>` / `<flywayPrefix>` parameters.
75
+
Kotlin schema migrations follow the same story as Java: the Java Maven plugin's
76
+
`meta:migrate` mojo was removed and there is no Kotlin-specific migrate command.
77
+
Schema migrations are owned by the TS toolchain:
72
78
73
79
```bash
74
-
mvn meta:migrate -Dflyway=true
80
+
meta migrate --db postgresql://... --slug initial
81
+
meta migrate --db postgresql://... --apply
75
82
```
76
83
77
84
### C#
@@ -100,9 +107,9 @@ for current status.)
100
107
101
108
| Port | Command | What it does |
102
109
|---|---|---|
103
-
| TypeScript |`meta verify`|Re-runs codegen as a no-op; reports DB-vs-metadata drift. |
104
-
| Java |`mvn meta:verify`| Introspects the live DB; fails the build if schema differs from metadata. |
105
-
| Kotlin |`mvn meta:verify`| Same as Java (shared Maven plugin). |
110
+
| TypeScript |`meta verify --db`|Introspects the live DB; reports DB-vs-metadata drift. |
111
+
| Java |`Renderer.verify`(build-time) + `MetaClassDBValidatorService` (startup) | Template-drift: verifies `{{...}}` references resolve against the payload VO. Live-DB-schema drift: startup validator asserts generated table objects match metadata. The `meta:verify` Maven goal (live-DB introspection) was removed. |
112
+
| Kotlin |`Renderer.verify`(build-time) + `MetadataStartupValidator` (startup) | Same as Java — template-drift and startup validation. No `meta:verify`Maven goal. |
106
113
| C# |`meta verify ./metadata --templates ./prompts`| Drift-checks templates against their payload VOs (FR-004 prompt-drift). |
107
114
| Python |`python -m metaobjects.render.verify`| Same as C# verify — template-vs-payload drift. |
Copy file name to clipboardExpand all lines: docs/ports/kotlin.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,10 +127,11 @@ reference covers the cross-port contract.
127
127
128
128
```bash
129
129
mvn compile # runs the codegen as part of generate-sources
130
-
mvn meta:migrate -Dflyway=true # emit V<N>__<slug>.sql under src/main/resources/db/migration/
131
-
mvn meta:verify # DB-vs-metadata drift gate
132
130
```
133
131
132
+
Schema migrations are owned by the TypeScript toolchain — see the
133
+
[Migrations section](../features/migrations-and-drift.md#kotlin) for the `meta migrate` commands.
134
+
134
135
## Use
135
136
136
137
For the `Author` example (see [entities.md](../features/entities.md)), the codegen
@@ -283,8 +284,8 @@ the contract is universal.
283
284
|---|---|---|
284
285
| Code-vs-DB |`KotlinEntityGenerator` + `KotlinExposedTableGenerator` (one metadata, two emitters) | Build time |
285
286
| Code-vs-API-doc | Cross-port codegen from same metadata | Build time |
286
-
| DB-vs-metadata |`meta:verify` Maven goal| CI on every PR |
287
-
| Migration-vs-metadata |`meta:migrate --flyway` emits from metadata diffs | Build time |
287
+
| DB-vs-metadata |`MetadataStartupValidator.validate(loader)` at Spring `ApplicationReadyEvent`; live-DB schema drift: TS toolchain `meta verify --db`|App startup; CI on every PR (TS)|
288
+
| Migration-vs-metadata |TS toolchain `meta migrate` emits from metadata diffs (`meta:migrate` Maven goal was removed)| Build time |
-**Runtime metadata** — OMDB persistence layer over modernized JDBC with Spring-`@Transactional` integration. FR-003 fully shipped: binding registry, typed jsonb codec, source/origin metamodel, atomic mapping cache + JDBC codec registry + `inTransaction` template (Plan 4). Schema migrations are owned by the TypeScript toolchain (`@metaobjectsdev/cli migrate`); the `meta:migrate` Maven goal was removed. OMDB retains a dev/test runtime auto-create path (`MetaClassDBValidatorService`).
13
+
-**Drift detection** — Template-drift: `Renderer.verify`checks `{{...}}` references against the payload VO at build time. Generated-table drift: `MetaClassDBValidatorService` asserts at startup. The live-DB-schema`meta:verify` Maven goal was removed.
14
14
-**Prompt construction** — `metaobjects-render` (Mustache + payload-VO + verify), FR-006 `template.output` parser-on-receipt codegen, render output byte-identical with the other four ports against the shared render-conformance corpus.
15
15
16
16
Fully green across all five cross-port conformance corpora: metamodel (85), yaml (6), persistence (12 against Testcontainers Postgres), render (4), verify (31).
-`--dry-run` — print SQL pair to stdout, write nothing
105
+
-`--apply` — after writing migration files, immediately apply all pending migrations against the DB (runs `up.sql` for each unapplied entry, tracked in the migration ledger). Mutually exclusive with `--rollback`. Postgres and SQLite only (D1 uses `--apply` to invoke `wrangler d1 migrations apply` instead).
106
+
-`--rollback <version>` — roll back applied migrations newer than `<version>` by running their `down.sql` in reverse order, ledger-tracked. Pass an empty string (`--rollback ""`) to roll back everything. Mutually exclusive with `--apply`. Postgres and SQLite only.
105
107
106
108
**D1-specific flags** (only relevant with `--dialect d1`):
107
109
-`--d1 <binding>` — explicit D1 binding from `wrangler.toml` (auto-detected when there's exactly one)
Copy file name to clipboardExpand all lines: server/typescript/packages/migrate-ts/README.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Schema migration tool for MetaObjects-driven projects.
5
5
Compares loaded MetaObjects metadata against a live Postgres or SQLite (libsql/Turso) database
6
6
and emits paired `up.sql` + `down.sql` migration files.
7
7
8
-
**Status:** v0.3. TS reference implementation; emits migration SQL but does not yet apply against the DB.
8
+
**Status:** v0.3. TS reference implementation. Emits migration SQL, applies pending migrations against the DB (`--apply`), and tracks migration history via a ledger table.
9
9
10
10
## Install
11
11
@@ -97,8 +97,6 @@ Targets Cloudflare D1 via the wrangler CLI. Connection is read from `wrangler.to
97
97
98
98
## Not yet shipped
99
99
100
-
-`meta migrate --apply` (apply migrations against the DB).
Copy file name to clipboardExpand all lines: spec/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The cross-language design documentation for the MetaObjects standard. This direc
6
6
7
7
A typed metadata standard for declaring entity models, identities, relationships, validations, views, layouts, and storage sources -- once, in a canonical form, then consumed by:
8
8
9
-
-**Code generators** that emit idiomatic per-language code (Drizzle/Zod + Fastify on TypeScript, JOOQ/Spring on Java, Pydantic/FastAPI on Python).
9
+
-**Code generators** that emit idiomatic per-language code (Drizzle/Zod + Fastify on TypeScript, Spring controllers + DTOs + repos via `codegen-spring` on Java, Pydantic/FastAPI on Python).
10
10
-**Runtime loaders** that read the metadata at runtime to drive CRUD, validation, relationships, dynamic admin UIs, and LLM tool registration.
11
11
-**Drift checks** that flag divergence between code and metadata via compile-time breakage in the type checker and through `meta migrate` against live databases.
12
12
-**Prompt construction***(the fourth pillar — planned for 7.0.0)* that makes an LLM prompt a declared, deterministic, testable artifact instead of a scattered string: a typed payload declared as a projection (so payload bloat is visible), external provider-resolved prompt text, a deterministic render that is snapshot-testable and cache-stable, and build-time prompt↔payload drift detection — conformance-gated so the guarantee holds in every language port. See the FR-004 design doc under [`../docs/superpowers/specs/`](../docs/superpowers/specs/).
0 commit comments