Skip to content

fix: default allowed contacts to regular, not emergency#19

Merged
creativeux merged 1 commit into
mainfrom
fix/allowed-contact-emergency-default
Jun 28, 2026
Merged

fix: default allowed contacts to regular, not emergency#19
creativeux merged 1 commit into
mainfrom
fix/allowed-contact-emergency-default

Conversation

@creativeux

Copy link
Copy Markdown
Owner

Problem

Pre-existing allowed contacts were all showing up as emergency contacts (ring any hour, bypass the schedule). Root cause: the l2m3n4o5p6q7 migration backfilled every existing row with UPDATE 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 False everywhere else (model, schema, service, repo, add-contact form) — the backfill was the only thing flipping them.

Changes

  1. l2m3n4o5p6q7 — remove the UPDATE ... SET emergency = true backfill. The column already has server_default=false, so environments that haven't applied this revision yet (production) get the correct default.
  2. 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.toml preDeployCommand = "alembic upgrade head":

Env l2m3n4o5p6q7 Result
Staging already applied (skipped) new migration resets rows → false
Production not yet applied edited migration runs (no backfill), then reset (no-op) ✅
Local already at new head (0 rows) no-op ✅

No manual downgrade/re-upgrade needed.

Safety

The emergency feature is unreleased (migration dated after v1.2.1), so no legitimate emergency=true values exist yet — the blanket reset is safe.

Tests

Full backend (654) and frontend (250) suites pass via precommit.

🤖 Generated with Claude Code

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>
@creativeux creativeux self-assigned this Jun 28, 2026
@creativeux creativeux merged commit f0a8ffb into main Jun 28, 2026
2 checks passed
@creativeux creativeux deleted the fix/allowed-contact-emergency-default branch June 28, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant