fix: default allowed contacts to regular, not emergency#19
Merged
Conversation
The l2m3n4o5p6q7 migration backfilled every existing allowed_contact to emergency=true, so all pre-existing contacts were treated as emergency (ring any hour, bypass the schedule). Contacts should default to regular allowed contacts and be upgraded to emergency only via the explicit per-contact toggle. - Remove the `UPDATE ... SET emergency = true` backfill from l2m3n4o5p6q7 so environments that haven't applied it yet get the correct default (the column already has server_default=false). - Add m3n4o5p6q7r8, a data-only corrective migration that resets all rows to emergency=false. Editing an already-applied migration is a no-op for Alembic, so this new revision is what fixes environments (e.g. staging) where the bad backfill already ran. It runs automatically via Railway's preDeployCommand (`alembic upgrade head`). The emergency feature is unreleased, so no legitimate emergency=true values exist yet; the blanket reset is safe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Pre-existing allowed contacts were all showing up as emergency contacts (ring any hour, bypass the schedule). Root cause: the
l2m3n4o5p6q7migration backfilled every existing row withUPDATE allowed_contact SET emergency = true.Contacts should default to regular allowed contacts (subject to the schedule) and be upgraded to emergency only via the explicit per-contact toggle. The flag already defaults to
Falseeverywhere else (model, schema, service, repo, add-contact form) — the backfill was the only thing flipping them.Changes
l2m3n4o5p6q7— remove theUPDATE ... SET emergency = truebackfill. The column already hasserver_default=false, so environments that haven't applied this revision yet (production) get the correct default.m3n4o5p6q7r8(new) — data-only corrective migration:UPDATE allowed_contact SET emergency = false. Editing an already-applied migration is a no-op for Alembic, so this fresh revision is what fixes environments where the bad backfill already ran (staging).Rollout
Runs automatically via
backend/railway.tomlpreDeployCommand = "alembic upgrade head":l2m3n4o5p6q7false✅No manual downgrade/re-upgrade needed.
Safety
The emergency feature is unreleased (migration dated after v1.2.1), so no legitimate
emergency=truevalues exist yet — the blanket reset is safe.Tests
Full backend (654) and frontend (250) suites pass via precommit.
🤖 Generated with Claude Code