Jul 16 - Update issue handler Janitorial staff - add input staff name
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""phase41 — issue internal_handler_name
|
||||
|
||||
Adds a free-text `internal_handler_name` to `issues`, capturing the name of the
|
||||
janitorial staff member who will handle an issue when handler_type == 'internal'.
|
||||
Distinct from `assigned_to` (the JQC User who owns follow-up) — the actual crew
|
||||
member may not be a system user.
|
||||
|
||||
Uses an INFORMATION_SCHEMA column-existence check — safe to re-run.
|
||||
"""
|
||||
|
||||
revision = 'phase41_internal_handler'
|
||||
down_revision = 'phase40_auditor_role'
|
||||
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_name'):
|
||||
op.execute(sa.text(
|
||||
"ALTER TABLE issues ADD COLUMN internal_handler_name VARCHAR(100) NULL"
|
||||
))
|
||||
|
||||
|
||||
def downgrade():
|
||||
bind = op.get_bind()
|
||||
if _column_exists(bind, 'issues', 'internal_handler_name'):
|
||||
op.execute(sa.text("ALTER TABLE issues DROP COLUMN internal_handler_name"))
|
||||
Reference in New Issue
Block a user