feat(db): add workbench schema comments

This commit is contained in:
2026-09-24 10:33:12 +08:00
parent 91afe76c6d
commit 1a6ff64bbe
5 changed files with 197 additions and 4 deletions
@@ -30,7 +30,6 @@ pytestmark = pytest.mark.skipif(
os.environ.get("OPERATIONAL_TASKS_STORAGE_TEST") != "1", reason="explicit PostgreSQL test opt-in required",
)
@pytest.fixture
def anyio_backend():
return "asyncio"
@@ -40,7 +39,13 @@ def anyio_backend():
async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back():
migration = "\n".join(
(Path(__file__).parents[2] / f"resources/sql/{name}").read_text()
for name in ("014_operational_tasks.sql", "015_workbench_events_and_task_runs.sql")
for name in (
"008_workbench_alert_events.sql",
"011_workbench_work_orders.sql",
"014_operational_tasks.sql",
"015_workbench_events_and_task_runs.sql",
"017_workbench_schema_comments.sql",
)
)
# The migration is normally atomic itself. This test owns an outer rollback
# transaction, so it executes its statements without transaction delimiters.
@@ -51,6 +56,16 @@ async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back(
try:
async with conn.transaction(force_rollback=True):
await conn.execute(migration)
comment_rows = await (
await conn.execute(
"""SELECT c.relname, obj_description(c.oid, 'pg_class') AS description
FROM pg_class c
JOIN pg_namespace n ON n.oid=c.relnamespace
WHERE n.nspname='workbench' AND c.relkind='r'""",
)
).fetchall()
assert len(comment_rows) >= 17
assert all(row["description"] for row in comment_rows)
repository = OperationalTaskRepository(conn, context.project_id)
service = OperationalTaskService(repository, context, permissions_for_context(context))
now = datetime.now(timezone.utc)