Dbmigration#275
Merged
Merged
Conversation
+ Add `alembic.ini` for migration configuration. + Implement migration commands in `justfile` for creating and checking migrations. + Create `tuttle/migrations/` directory with environment and README files. + Establish schema change workflow in `AGENTS.md` and `tuttle/model.py`. + Add migration integrity tests in `tuttle_tests/test_migrations.py`. + Ensure schema management in `tuttle/db_schema.py` using Alembic. + Introduce initial migration script in `tuttle/migrations/versions/0001_initial_schema.py`. + Document migration process and rules in `tuttle/migrations/README.md`.
Tuttle is a single-user desktop app: rolling back a schema is destructive (data in dropped columns is gone) and offers nothing over restoring the .bak-<ts> snapshot that ensure_schema() already takes before every upgrade. Make this explicit across the migration system. - script.py.mako: every generated revision's downgrade() now raises NotImplementedError with a clear pointer to the .bak recovery path - 0001_initial_schema.py: replaced the autogenerated drop_table chain with the same NotImplementedError - schema-migrations.mdc + migrations/README.md: document the policy and the dev "undo via delete revision + just reset" workflow - test_migrations.py: new test_downgrades_are_not_supported walks every revision's AST and fails on real downgrade bodies Also fold in two infrastructure fixes exposed by a dry-run of the full migration workflow: - justfile: `@echo` only works as a recipe-prefix in just, not as a shell command inside a #!/usr/bin/env bash recipe body. The migrate recipe's reminder banner was failing silently with exit 127. - test_migrations.py: the chain-test's naive INSERT ignored NOT NULL constraints. Introspect column metadata and supply type-appropriate seed values via a new _seed_value helper so the test exercises a real upgrade path when a second revision exists. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scope: database migration