aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/db
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-13 21:41:28 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-13 21:41:28 +0200
commit5d9b2c03fb6bdd28e4c233a35005c709cdd3760c (patch)
treecb914653f2d84be5618532ea67902ea6e056ca62 /packages/meshbay-hub/src/meshbay_hub/db
parentdd7d9c80baafe08287516fd4d486223b5199b102 (diff)
downloadmeshbay-5d9b2c03fb6bdd28e4c233a35005c709cdd3760c.tar.gz
fix(hub): the migration chain runs, and a test says so
`add_email_verification` wrote PostgreSQL's `(now() at time zone 'utc')` as a literal server default, where every other migration in the chain uses `sa.func.now()` and lets the dialect render it. On SQLite that is `sqlite3.OperationalError: near "at": syntax error` — so `meshbay-hub migrate` could not reach head on the database the suite and the documented local-hub workflow both use. Which is how it survived: the only test that ran alembic at all stopped at `c3d4e5f6a7b8`, the revision immediately before it. The two newest migrations — email verification, and the mail quota committed two days ago — had been run by exactly one thing, a production deploy, and the newest by nothing at all. `test_migrations_reach_head.py` upgrades to head and compares what that built against `Base.metadata`, both directions: a column in the models and in no migration never reaches production, and one in the migrations and in no model is a rename abandoned halfway. Both tests fail on the unfixed migration with the error above; the drift half was checked by adding a model column on purpose and watching it be named. The schemas agree today. It still does not check PostgreSQL-only behaviour — a default, an index type or a constraint one dialect accepts and the other refuses. Running the chain somewhere beats running it nowhere, and is not the same as running it where it ships. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMxEQadpzPkYLFf5CYKhpW
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/d4e5f6a7b8c9_add_email_verification.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/d4e5f6a7b8c9_add_email_verification.py b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/d4e5f6a7b8c9_add_email_verification.py
index 20ba29d..6741eb8 100644
--- a/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/d4e5f6a7b8c9_add_email_verification.py
+++ b/packages/meshbay-hub/src/meshbay_hub/db/migrations/versions/d4e5f6a7b8c9_add_email_verification.py
@@ -34,8 +34,14 @@ def upgrade() -> None:
sa.Column('purpose', sa.String(16), nullable=False),
sa.Column('user_id', sa.String(36), sa.ForeignKey('users.id'), nullable=True),
sa.Column('group_id', sa.String(36), sa.ForeignKey('groups.id'), nullable=True),
+ # `sa.func.now()`, as every other migration in this chain uses: the
+ # dialect running it renders it. Written out as PostgreSQL's
+ # `(now() at time zone 'utc')`, this was a syntax error on SQLite — so
+ # the chain could not reach head on the database the suite and the
+ # local-hub workflow both use, and the two newest migrations had been
+ # run by exactly one thing: a production deploy.
sa.Column('created_at', sa.DateTime(timezone=True),
- server_default=sa.text("(now() at time zone 'utc')")),
+ server_default=sa.func.now()),
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('verified_at', sa.DateTime(timezone=True), nullable=True),
sa.Column('attempts', sa.Integer, server_default='0'),