fix: enforce durable migration ownership and readiness
This commit is contained in:
parent
14befd0b50
commit
826874a47e
5 changed files with 52 additions and 0 deletions
12
hub_core/migrations/roles.py
Normal file
12
hub_core/migrations/roles.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
|
||||
def migration_role_statement(role: str | None) -> str | None:
|
||||
"""Return a safely quoted SET ROLE statement for an admitted owner role."""
|
||||
if not role:
|
||||
return None
|
||||
if not re.fullmatch(r"[a-z_][a-z0-9_]{0,62}", role):
|
||||
raise ValueError("HUB_CORE_MIGRATION_ROLE is not a safe PostgreSQL role name")
|
||||
return f'SET ROLE "{role}"'
|
||||
Loading…
Add table
Add a link
Reference in a new issue