no-mistakes(review): Extend legacy self-heal rename; clear stale Mould & Damp priority default
This commit is contained in:
+11
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user