diff --git a/app/main.py b/app/main.py index ccdc7d5..81094dd 100644 --- a/app/main.py +++ b/app/main.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) async def ensure_legacy_schema(conn) -> None: - """Add columns from alembic migrations that legacy create_all databases lack.""" + """Add columns/data changes from alembic migrations that legacy create_all databases lack.""" result = await conn.execute(text("PRAGMA table_info(categories)")) columns = {row[1] for row in result} if "show_in_form" not in columns: @@ -28,6 +28,16 @@ async def ensure_legacy_schema(conn) -> None: text("ALTER TABLE categories ADD COLUMN show_in_form BOOLEAN NOT NULL DEFAULT 1") ) logger.info("Added missing categories.show_in_form column (legacy database)") + result = await conn.execute( + text( + "UPDATE categories SET name = 'Missing Item' " + "WHERE type = 'cs' AND name = 'Lost Property' AND parent_id IS NULL " + "AND NOT EXISTS (SELECT 1 FROM categories c2 " + "WHERE c2.type = 'cs' AND c2.name = 'Missing Item' AND c2.parent_id IS NULL)" + ) + ) + if result.rowcount: + logger.info("Renamed legacy 'Lost Property' category to 'Missing Item'") @asynccontextmanager diff --git a/app/templates/tickets/new.html b/app/templates/tickets/new.html index 204a55b..461f638 100644 --- a/app/templates/tickets/new.html +++ b/app/templates/tickets/new.html @@ -111,19 +111,19 @@