ORM-26: Add Model::schema() and a schema drift check #26
Labels
No labels
area:core
area:database
area:migrations
area:model
area:relations
area:schema
area:tests
breaking-change
size:M
size:S
tracking
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
NoctisWolfshadow/tessera-orm#26
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Depends on: #17, #25
Context
Models and migrations are written separately, so they can disagree. Rather than generating migrations from models (risky with SQLite's limited
ALTER), a hand-writtenModel::schema()describes what the model expects, and a verifier compares it with the real database. It is a safety net for tests and CI.Tasks
fn schema() -> Option<TableSchema>(defaultNone) describing columns with type and nullability, the PK and foreign keys.Schema::verify::<M>() -> Result<Vec<Drift>>compares againstPRAGMA table_infoandPRAGMA foreign_key_list. ADriftnames the table, the column and the difference (missing column, type mismatch, nullability, missing FK).Migrator::run(), verify every fixture model.Example
What a
Driftlooks like (Display):Acceptance criteria