06/22 Update database to fix inspection notify

This commit is contained in:
Nguyen Ngo
2026-06-22 13:02:01 -04:00
parent 5c9f12289c
commit b131b06e2c
@@ -0,0 +1,37 @@
"""phase28 — restore inspection_completed director notification
The notification_matrix row for ('inspection_completed', 'director') was set
to enabled=False at some point — likely when an admin saved the notification
matrix page with the director checkbox accidentally unchecked.
This migration resets that row to enabled=True (matching MATRIX_DEFAULTS) so
the director receives email and in-app notifications whenever an inspector
submits a completed inspection, from both the web UI and the mobile API.
Also resets ('inspection_completed', 'admin') and ('inspection_completed', 'customer')
to True for the same reason — any of these could have been inadvertently disabled.
Rows that do not yet exist in the DB are left alone; MATRIX_DEFAULTS covers
those at runtime.
"""
from alembic import op
revision = 'phase28_fix_inspection_notify'
down_revision = 'phase27_score_alerts'
branch_labels = None
depends_on = None
def upgrade():
op.execute("""
UPDATE notification_matrix
SET enabled = 1
WHERE event_type = 'inspection_completed'
AND role_key IN ('admin', 'director', 'customer')
""")
def downgrade():
# No safe rollback — we don't know what the values were before.
pass