"""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