Problem
-
Every brand-new database replays all 6 migrations in sequence, even though several steps are now pointless for a fresh install (migration002 repairs pre-existing bad data; migration003's pre-seed INSERTs are WHERE EXISTS-guarded no-ops; migration004 creates a table that migration006 immediately renames moments later in the same startup). A fresh database should be created directly at the current schema in one step.
-
Migration ownership is tangled. AuditMigrations.CreateAuditEntriesTable/RenameAuditEntriesToSystemAuditEntries (the SQL text) physically live in Quotinator.Data — but when they run is decided by Quotinator.Engine's QuotinatorMigrations.All, which interleaves them at arbitrary positions among its own domain migrations. Quotinator.Data should own and maintain the scripts for its own tables (System_AuditEntries, System_SchemaVersion, and any future System_* table), and DatabaseInitializer should always apply Data's own scripts first, before the consuming project's scripts — not interleaved, and not controlled by the consumer.
-
Version numbering must stay stable per project. With Data and Engine sharing one counter, "version N" is only meaningful relative to however many Data-owned migrations currently exist — if Data adds a migration later, every one of Engine's migration numbers silently shifts. Separate version-tracking tables fix this: System_SchemaVersion tracks only Data's own migrations, a new System_ConsumerSchemaVersion tracks the consumer's own migrations independently.
Scope
Quotinator.Data's DatabaseInitializer gets its own fixed, internal DataOwnedMigrations list (not passed via constructor) and its own baseline fragment (DataBaselineSql) for System_AuditEntries — always applied/created first.
- Two separate version tables:
System_SchemaVersion (Data's own count) and System_ConsumerSchemaVersion (new — the consumer's own count).
- A fresh (zero-table) database takes a one-step baseline path instead of replaying migration history; an existing database continues through the unchanged incremental path.
- Drift-detection tests ensure the baseline can never silently go stale relative to the numbered migrations, on both the Data side and the Engine side.
Quotinator.Engine's migration constant names are renumbered to match their actual local position (no more "Migration005 is actually the 4th migration").
Full design: see the plan doc under docs/milestones/data-import-sources/.
Since nothing has shipped in a release yet, existing dev databases picking up this restructuring via a Reset (already a supported admin operation) is acceptable — no upgrade-in-place path is required.
Problem
Every brand-new database replays all 6 migrations in sequence, even though several steps are now pointless for a fresh install (migration002 repairs pre-existing bad data; migration003's pre-seed
INSERTs areWHERE EXISTS-guarded no-ops; migration004 creates a table that migration006 immediately renames moments later in the same startup). A fresh database should be created directly at the current schema in one step.Migration ownership is tangled.
AuditMigrations.CreateAuditEntriesTable/RenameAuditEntriesToSystemAuditEntries(the SQL text) physically live inQuotinator.Data— but when they run is decided byQuotinator.Engine'sQuotinatorMigrations.All, which interleaves them at arbitrary positions among its own domain migrations.Quotinator.Datashould own and maintain the scripts for its own tables (System_AuditEntries,System_SchemaVersion, and any futureSystem_*table), andDatabaseInitializershould always apply Data's own scripts first, before the consuming project's scripts — not interleaved, and not controlled by the consumer.Version numbering must stay stable per project. With Data and Engine sharing one counter, "version N" is only meaningful relative to however many Data-owned migrations currently exist — if Data adds a migration later, every one of Engine's migration numbers silently shifts. Separate version-tracking tables fix this:
System_SchemaVersiontracks only Data's own migrations, a newSystem_ConsumerSchemaVersiontracks the consumer's own migrations independently.Scope
Quotinator.Data'sDatabaseInitializergets its own fixed, internalDataOwnedMigrationslist (not passed via constructor) and its own baseline fragment (DataBaselineSql) forSystem_AuditEntries— always applied/created first.System_SchemaVersion(Data's own count) andSystem_ConsumerSchemaVersion(new — the consumer's own count).Quotinator.Engine's migration constant names are renumbered to match their actual local position (no more "Migration005 is actually the 4th migration").Full design: see the plan doc under
docs/milestones/data-import-sources/.Since nothing has shipped in a release yet, existing dev databases picking up this restructuring via a Reset (already a supported admin operation) is acceptable — no upgrade-in-place path is required.