Own migrate objects as audit_core_migrate; pin snapshot-read image
SET ROLE during migrate so tables are not owned by a disposable lease. Current image sha256:aec5575. T02/T03 recorded done after live rotation and rollout undo. T05 remote run is partial (port-forward dropped).
This commit is contained in:
parent
c404c910cd
commit
53df641866
4 changed files with 42 additions and 13 deletions
|
|
@ -204,6 +204,13 @@ class PostgresAuditBackend:
|
|||
applied: list[str] = []
|
||||
try:
|
||||
with self.pool.connection() as conn:
|
||||
migrate_role = os.environ.get("AUDIT_CORE_MIGRATE_ROLE", "").strip()
|
||||
if migrate_role:
|
||||
if not migrate_role.isidentifier():
|
||||
raise ValueError(f"unsafe migrate role: {migrate_role!r}")
|
||||
# Leased login roles must SET ROLE to the group so new
|
||||
# objects are owned by audit_core_migrate, not the lease.
|
||||
conn.execute(f'SET ROLE "{migrate_role}"')
|
||||
conn.execute(f'CREATE SCHEMA IF NOT EXISTS "{self.schema}"')
|
||||
conn.execute(
|
||||
f'CREATE TABLE IF NOT EXISTS "{self.schema}".schema_migrations ('
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue