Jul 10 - Update codes to catch up with the single tenant project

This commit is contained in:
2026-07-10 12:29:44 -04:00
parent faab9fd008
commit e41998b561
12 changed files with 375 additions and 13 deletions
@@ -0,0 +1,57 @@
"""Add handler_type and facility-handler fields to issues (phase39).
Tracks who is responsible for resolving an issue:
internal — janitorial staff (default / NULL)
facility — building / facility staff (adds name/contact/notes sub-fields)
vendor — external contractor (already tracked via vendor_* columns)
All columns are nullable so existing rows are unaffected (NULL == 'internal').
Uses INFORMATION_SCHEMA existence checks — safe to re-run.
"""
from alembic import op
import sqlalchemy as sa
revision = 'phase39_issue_handler_type'
down_revision = 'phase38_facility_qr'
branch_labels = None
depends_on = None
def _col_exists(conn, table, column):
row = 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}).scalar()
return bool(row)
def upgrade():
conn = op.get_bind()
if not _col_exists(conn, 'issues', 'handler_type'):
op.add_column('issues', sa.Column(
'handler_type',
sa.Enum('internal', 'facility', 'vendor'),
nullable=True,
))
if not _col_exists(conn, 'issues', 'facility_handler_name'):
op.add_column('issues', sa.Column(
'facility_handler_name', sa.String(100), nullable=True))
if not _col_exists(conn, 'issues', 'facility_handler_contact'):
op.add_column('issues', sa.Column(
'facility_handler_contact', sa.String(200), nullable=True))
if not _col_exists(conn, 'issues', 'facility_handler_notes'):
op.add_column('issues', sa.Column(
'facility_handler_notes', sa.Text, nullable=True))
def downgrade():
op.drop_column('issues', 'facility_handler_notes')
op.drop_column('issues', 'facility_handler_contact')
op.drop_column('issues', 'facility_handler_name')
op.drop_column('issues', 'handler_type')