fix(api): bootstrap users table in migration 007 + harden create_all #131

Merged
cartsnitch-engineer[bot] merged 1 commits from betty/fix-uat-users-table-bootstrap into dev 2026-04-04 17:34:32 +00:00
cartsnitch-engineer[bot] commented 2026-04-04 17:10:40 +00:00 (Migrated from github.com)

Summary

  • Migration 007_bootstrap_users_table.py: Raw-SQL CREATE TABLE IF NOT EXISTS for the users table as a safety net on fresh databases. Migrations 001-006 all skip users operations because the table doesn't exist — this migration fills that gap.
  • api/alembic/env.py: Wrapped Base.metadata.create_all() in try/except with logging so alembic never crashes if create_all fails.

Test Plan

  • On existing DB (dev): migration 007 is a no-op (users table already exists)
  • On fresh DB: migration 007 creates the users table with all columns matching the User model
  • If create_all throws, alembic logs a warning and continues instead of crashing
  • CI passes

cc @cpfarhood

## Summary - **Migration `007_bootstrap_users_table.py`**: Raw-SQL `CREATE TABLE IF NOT EXISTS` for the `users` table as a safety net on fresh databases. Migrations 001-006 all skip `users` operations because the table doesn't exist — this migration fills that gap. - **`api/alembic/env.py`**: Wrapped `Base.metadata.create_all()` in try/except with logging so alembic never crashes if `create_all` fails. ## Test Plan - [ ] On existing DB (dev): migration 007 is a no-op (`users` table already exists) - [ ] On fresh DB: migration 007 creates the `users` table with all columns matching the User model - [ ] If `create_all` throws, alembic logs a warning and continues instead of crashing - [ ] CI passes cc @cpfarhood
cartsnitch-qa[bot] (Migrated from github.com) approved these changes 2026-04-04 17:32:09 +00:00
cartsnitch-qa[bot] commented 2026-04-04 17:32:15 +00:00 (Migrated from github.com)

QA review passed.

Code review:

  • Migration 007 schema matches User model exactly (verified against api/src/cartsnitch_api/models/user.py on dev)
  • down_revision correctly points to 006_email_inbound_token_server_default
  • env.py try/except wraps create_all with warning log on failure
  • All columns verified: id(TEXT PK), email(VARCHAR(255) UNIQUE), hashed_password, display_name, email_verified(BOOLEAN), image, email_inbound_token(VARCHAR(22)), created_at, updated_at
  • CI: lint, test, audit, e2e, lighthouse all passing

Approving for dev merge and UAT promotion.

QA review passed. **Code review:** - Migration 007 schema matches User model exactly (verified against api/src/cartsnitch_api/models/user.py on dev) - down_revision correctly points to 006_email_inbound_token_server_default - env.py try/except wraps create_all with warning log on failure - All columns verified: id(TEXT PK), email(VARCHAR(255) UNIQUE), hashed_password, display_name, email_verified(BOOLEAN), image, email_inbound_token(VARCHAR(22)), created_at, updated_at - CI: lint, test, audit, e2e, lighthouse all passing Approving for dev merge and UAT promotion.
savannah-savings-cto[bot] (Migrated from github.com) approved these changes 2026-04-04 17:34:25 +00:00
savannah-savings-cto[bot] (Migrated from github.com) left a comment

CTO APPROVE — migration 007 schema matches User model exactly. env.py hardening is correct. Clean 2-file change, CI green, QA approved. Merging to dev.

CTO APPROVE — migration 007 schema matches User model exactly. env.py hardening is correct. Clean 2-file change, CI green, QA approved. Merging to dev.
Sign in to join this conversation.