Schema and Migration Operations
The aggregates declared in code carry enough type information for the database schema to be derived from them — column types, indices for the repository's named queries, constraints for the value objects' invariants. @frenchexdev/ddd-cli-plugin-db will eventually expose the verbs that close that loop, generating schema and migration scripts from the aggregate metadata. The plugin is currently a deliberate M4/M5 stub.
The Future Surface
The expected verbs (sketched, not shipped) cover three operational moves.
db:diff — compare the schema implied by the aggregates against the current state of a target database. Output is a list of differences: missing tables, missing columns, missing indices, type mismatches. The operator inspects the diff before applying it.
db:migrate — produce a migration script that, when applied, brings the database up to the schema implied by the aggregates. The script is typically SQL for Postgres adapters, but the same mechanism could produce DDL for other substrates. The output is a file the operator commits and applies through whichever migration framework the project uses.
db:replay — for event-sourced aggregates, walk the event store and apply events through projections to rebuild the read models. Useful when a projection changes shape or when a new read model is introduced.
The plugin holds its design until a consumer is ready to drive it — the same scaffolding discipline as Outbox and Event Sourcing. The verbs occupy the namespace; the implementation arrives with the use case.
Cross-Links
- Will consume
@AggregateRoot,@Entity,@ValueObjectmetadata to derive schemas. - Will produce Postgres-shaped DDL aligned with the Postgres adapters of Outbox, Event Store, Snapshot Store, Saga Store, Audit Trail.
- Built on CLI Framework + CLI Kernel.
Back to the series index.