Skip to content

Dbmigration#275

Merged
clstaudt merged 2 commits into
mainfrom
dbmigration
May 27, 2026
Merged

Dbmigration#275
clstaudt merged 2 commits into
mainfrom
dbmigration

Conversation

@clstaudt
Copy link
Copy Markdown
Contributor

@clstaudt clstaudt commented May 27, 2026

scope: database migration

clstaudt and others added 2 commits May 27, 2026 14:38
+ 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>
@clstaudt clstaudt merged commit dc72290 into main May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant