Seed the guard fixture's project into the tenant schema it now lives in

public.projects does not exist since 0005, and this fixture was the last place
still writing to it. The project row moves into the organization's own schema
under an unqualified name, which is also the shape production writes it in - so
the artifact and job rows guarded by these tests are being set up the way the
application would set them up rather than the way the old shared table allowed.
This commit is contained in:
umbra audio
2026-10-03 13:40:48 -07:00
parent 152735f145
commit 7b12964a9b

View File

@@ -73,9 +73,19 @@ def guard_world():
"INSERT INTO public.organizations (id, name, slug) VALUES (%s, %s, %s)",
(org, f"Guard World {org.hex[:8]}", f"guard-world-{org.hex[:8]}"),
)
# The project is per-tenant since migration 0005, so it goes into the
# organization's own schema - the one the trigger just created for it - under
# an unqualified name. `public.projects` does not exist any more, and this
# file cannot insert anywhere else without testing something other than the
# guards it exists to test.
cursor.execute(
"INSERT INTO public.projects (id, organization_id, name, slug) VALUES (%s, %s, %s, %s)",
(project, org, f"Guard Book {project.hex[:8]}", f"guard-book-{project.hex[:8]}"),
"SELECT set_config('search_path', "
"'\"' || app.tenant_schema_name(%s::uuid) || '\", public', true)",
(org,),
)
cursor.execute(
"INSERT INTO projects (id, name, slug) VALUES (%s, %s, %s)",
(project, f"Guard Book {project.hex[:8]}", f"guard-book-{project.hex[:8]}"),
)
# `content_hash` carries a format CHECK, so a placeholder string would be
# refused for the wrong reason and the refusal would read as the guard