Fix pgvector extension ownership — remove CREATE EXTENSION from migration #126
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-api#126
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lineage
plan-2026-02-26-tf-modularize-postgres→ Phase 6 → Phase 6b-1 (extension ownership fix)Repo
forgejo_admin/pal-e-docs(migration fix)forgejo_admin/deployments(CNPG CRD — extension provisioning)User Story
As a platform operator
I want pgvector extension creation to follow the platform-provides/app-consumes pattern
So that Alembic migrations don't need superuser privileges and fresh deployments work without manual intervention
Context
PR #122 added a pgvector schema migration that includes
CREATE EXTENSION IF NOT EXISTS vector. This fails at deploy time because the Alembic migration runs as thepaledocsapp user, which is NOT a superuser.CREATE EXTENSIONrequires superuser privileges in PostgreSQL.We fixed this manually by running
CREATE EXTENSIONas thepostgressuperuser viakubectl exec. But this is a band-aid — the migration will fail again on any fresh cluster bootstrap.The enterprise fix follows the same pattern as CNPG itself: platform provides the extension, app assumes it exists.
File Targets
pal-e-docs (migration fix):
alembic/versions/l2g3h4i5j6k7_add_vector_embeddings.py— removeCREATE EXTENSION IF NOT EXISTS vectorfromupgrade(). Replace with a check that the extension exists (raise informative error if not). RemoveDROP EXTENSIONfromdowngrade().deployments (CNPG CRD — extension provisioning):
bootstrap.initdb.postInitApplicationSQLor equivalent, so the extension is created automatically on cluster bootstrap as superuser. Example:Acceptance Criteria
CREATE EXTENSION— it checks and fails with a clear error if the extension is missingDROP EXTENSIONTest Expectations
pytest tests/ -vpassesConstraints
Checklist
Related
phase-postgres-6-vector-search— parent phaseplan-2026-02-26-tf-modularize-postgresArchitecture Revision — "platform provides capability, apps consume it"