db-schema-change
Skill0 starsChanged 3 months agoMITView on GitHub
How to change the task database schema in this repository — Alembic revisions, the legacy-database stamping heuristic, dual-store (SQLite + Firestore) updates, and the required migration tests. Use this BEFORE adding, renaming, or removing any column or table, changing an enum, or touching app/models.py, app/migrate.py, or migrations/ — even for a "trivial" new field.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- hiroppy/mf-dashboardtheir own version, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- hiroppy/mf-dashboard★ 426same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- daily-task-ritualSkill
- mcp-tool-changeSkill
- ship-releaseSkill
- task-board-workerSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
add the new column to the expected-columns assertions.
- Very specific: line 43
keep the legacy-upgrade test honest: its LEGACY_TASKS_TABLE SQL reproduces the 0.3.x schema and must NOT gain your new column — the test …
- Very specific: line 46
run the full suite (.venv/bin/pytest -q) — conftest exercises the stamping path on every run.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Changing the schema
Schema changes here must work for three kinds of databases at once: fresh
installs, databases created by pre-0.4.0 releases via create_all (no
alembic_version table), and Firestore documents that never migrate. A change
that only works for your local fresh DB will corrupt or crash real user
installs on their next git pull, which is why create_all is never the
answer.
Steps
- New Alembic revision in
migrations/versions/, numbered sequentially (0003_...py), usingmigrations/versions/0002_add_task_external_id.pyas the template. Hardcode enum value lists in the migration — do not import app models into migration files; migrations must stay frozen while models evolve. - Update the model and schemas together:
app/models.py(column),app/schemas.py(TaskBase/TaskUpdate/TaskRead fields with validation constraints). New fields must be optional or have defaults — old rows and old Firestore documents will not have them. - Update the stamping heuristic in
app/migrate.py. It detects databases withoutalembic_versionand decides which revision they match by inspecting thetaskscolumns (currently:external_idpresent → head, absent →0001). When your revision adds a column, make that column the new marker and bumpHEAD_REVISION; otherwise a freshcreate_all-shaped database (the test suite creates these) gets stamped too low and the upgrade fails on an already-existing column. - Both stores:
SqliteTaskStoreusually needs nothing beyond the model;FirestoreTaskStoreis schemaless but needs the field handled inencode_task_data(enums → values) and must tolerate documents missing the field (defaults inTaskReadcover this). - Tests — extend
tests/test_migrations.py:- add the new column to the expected-columns assertions;
- keep the legacy-upgrade test honest: its
LEGACY_TASKS_TABLESQL reproduces the 0.3.x schema and must NOT gain your new column — the test proves old databases upgrade cleanly with data intact; - run the full suite (
.venv/bin/pytest -q) — conftest exercises the stamping path on every run.
Gotchas learned the hard way
- SQLite ignores timezone info:
DateTime(timezone=True)columns come back naive. Application code normalizes naive datetimes as UTC (_normalized_datetimein app/main.py); keep that assumption. - SQLite ALTER is limited — plain ADD COLUMN is fine; anything structural
(drop/rename/constraint change) needs batch mode, which
migrations/env.pyalready enables viarender_as_batchfor SQLite. - Unique + nullable works on SQLite (multiple NULLs allowed) — that is why
external_idcan be both optional and unique.
Ship the change via the ship-release skill; schema releases are minor
version bumps.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

