fix: commit migration role assumption
All checks were successful
Build and Publish Container Image / build-and-push (push) Successful in 41s
All checks were successful
Build and Publish Container Image / build-and-push (push) Successful in 41s
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02b22-9638-76d2-bbff-b7ea1770b118
This commit is contained in:
parent
9751927d38
commit
b1fd3ec131
4 changed files with 32 additions and 3 deletions
|
|
@ -21,7 +21,7 @@ from sqlalchemy import (
|
|||
create_engine,
|
||||
event,
|
||||
)
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.engine import Connection, Engine
|
||||
|
||||
NAMING_CONVENTION = {
|
||||
"ix": "ix_%(table_name)s_%(column_0_name)s",
|
||||
|
|
@ -130,6 +130,15 @@ def database_url(value: str | Path) -> str:
|
|||
return text
|
||||
|
||||
|
||||
def assume_migration_role(connection: Connection, role: str) -> None:
|
||||
"""Assume the durable owner without leaving Alembic inside an outer txn."""
|
||||
connection.exec_driver_sql(f'SET ROLE "{role}"')
|
||||
# SQLAlchemy 2 autobegins on SET ROLE. Commit that transaction before
|
||||
# Alembic opens its own so the migration transaction is not rolled back
|
||||
# when the connection closes. SET ROLE remains active for the session.
|
||||
connection.commit()
|
||||
|
||||
|
||||
def _dynamic_connection_factory(url_file: Path):
|
||||
def connect():
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue