fix(api): NormalizeUserEmailsLower — real table name is users, not Users #195
No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!195
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/migration-users-table-casing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Staging outage
Staging API has been crash-looping since the 2026-11-12 14:04 deploy (
app-api-1Restarting(139), 1400+ restarts, ~21h of downtime; staging-deploy smoke has been red on every run since —/health/never answered).Cause:
20261112053648_NormalizeUserEmailsLower(#186) contains hand-written raw SQL referencing"Users"— the staging schema is snake_case tables (users) with PascalCase columns (users.Email,folders.IsTenantRoot; see appliedAddUserPanicLock, which correctly usestable: "users"). Postgres quoted identifiers are case-sensitive →42P01: relation "Users" does not exist→ unhandled exception in startupMigrateAsync(Program.cs:564) → crash → docker restart → repeat.UniqueTenantRoot(20261112081825, #193) is correct as written — it never ran because this migration crashed first.Fix
One line:
"Users"→users(unquoted lowercase, matching the raw-SQL style of UniqueTenantRoot).Safe to edit in place: no database has ever applied this migration (any DB with the real schema would crash identically); CI tests use EnsureCreated and never apply migrations.
Verification (local, fresh Postgres container)
ERROR: relation "Users" does not exist(42P01) — byte-identical to the staging crash logs.dotnet ef database updatefrom an empty DB applies all 45 migrations cleanly;ix_folders_one_tenant_rootunique index created; history ends atUniqueTenantRoot.dotnet buildclean (0 errors).After merge
staging-deploy auto-fires (paths filter matches
src/FailSulit.Api/**) → container should converge, both pending migrations apply,/health/answers, admin portal (/adminis baked into the api image) comes back with the #187 fix finally live.Follow-up
Will file: Postgres migration smoke test (apply-all on a real fresh DB + boot) so hand-written SQL gets exercised in CI — this exact bug class (15h+ staging downtime) currently has zero coverage.
users, notUsers