diff --git a/app/main.py b/app/main.py index e10f27e..d45289d 100644 --- a/app/main.py +++ b/app/main.py @@ -38,6 +38,14 @@ async def ensure_legacy_schema(conn) -> None: text("ALTER TABLE tickets ADD COLUMN phone VARCHAR(50)") ) logger.info("Added missing tickets.phone column (legacy database)") + if "reported_at" not in ticket_columns: + await conn.execute( + text("ALTER TABLE tickets ADD COLUMN reported_at DATETIME") + ) + await conn.execute( + text("UPDATE tickets SET reported_at = created_at WHERE reported_at IS NULL") + ) + logger.info("Added missing tickets.reported_at column (legacy database)") result = await conn.execute( text( "UPDATE categories SET name = 'Missing Item' "