Jul 16 - Update issue handler Janitorial staff - add input staff contact

This commit is contained in:
2026-07-16 15:48:15 -04:00
parent 66dbf31c34
commit 56bcf9ed63
8 changed files with 89 additions and 17 deletions
@@ -0,0 +1,39 @@
"""phase42 — issue internal_handler_contact
Adds `internal_handler_contact` (phone or email) to `issues`, the contact for the
janitorial staff member who will handle an issue when handler_type == 'internal'.
Parallels `internal_handler_name` (phase41) and the facility/vendor contact fields.
Uses an INFORMATION_SCHEMA column-existence check — safe to re-run.
"""
revision = 'phase42_internal_contact'
down_revision = 'phase41_internal_handler'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def _column_exists(conn, table, column):
result = conn.execute(sa.text(
"SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS "
"WHERE TABLE_SCHEMA = DATABASE() "
"AND TABLE_NAME = :t AND COLUMN_NAME = :c"
), {"t": table, "c": column})
return result.scalar() > 0
def upgrade():
bind = op.get_bind()
if not _column_exists(bind, 'issues', 'internal_handler_contact'):
op.execute(sa.text(
"ALTER TABLE issues ADD COLUMN internal_handler_contact VARCHAR(200) NULL"
))
def downgrade():
bind = op.get_bind()
if _column_exists(bind, 'issues', 'internal_handler_contact'):
op.execute(sa.text("ALTER TABLE issues DROP COLUMN internal_handler_contact"))