Module migration
event-store or projection-store only.Expand description
The schema, and the one way it is applied.
§Why a file rather than a sqlx::migrate!
The manifest carries the argument in full. The short form: a migrator’s
_sqlx_migrations table is per schema, one per fixture instance, about a
history this crate makes moot: every migration is IF NOT EXISTS, so apply
runs them all against any schema, fresh or migrated by an older build. Since
#420 the log has two, MIGRATION_1 and MIGRATION_3 (named: event-store).
§Why the SQL is include_str!d rather than written inline
happenstance-sqlite keeps its MIGRATION_1 as a &str constant in Rust
and mirrors it into a doc comment, then has a test compare the mirror against
sqlite_master object by object — because the two copies drift otherwise. A
.sql file has no second copy to drift from, gets SQL syntax highlighting in
every editor, and is the artefact a DBA asks for when they want to know what
this crate will do to their database. include_str! means it is still
compiled in, so a published crate carries its own schema and a consumer needs
nothing from this repository to apply it.
Constants§
- MIGRATION_
1 event-store - The event log’s first migration, as SQL;
MIGRATION_3follows it. - MIGRATION_
2 projection-store - The projection store’s schema, as SQL.
- MIGRATION_
3 event-store - The event log’s second migration, as SQL: the write-group columns and their index (#420).
- PROJECTION_
SCHEMA_ VERSION projection-store - The projection schema version this crate’s code is written against.
- SCHEMA_
VERSION event-store - The event log’s schema version.
Functions§
- apply
event-store - Applies
MIGRATION_1and thenMIGRATION_3to whatever schemaexecutorresolves against. - apply_
projection projection-store - Applies
MIGRATION_2to whatever schemaexecutorresolves against.