fix(migrations): harden BAT-025 PostgreSQL verification
This commit is contained in:
+3
-2
@@ -10,13 +10,14 @@ from app.core.config import get_settings
|
||||
config = context.config
|
||||
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
# Alembic may run in-process (bootstrap/tests); preserve application loggers.
|
||||
fileConfig(config.config_file_name, disable_existing_loggers=False)
|
||||
|
||||
target_metadata = None
|
||||
|
||||
|
||||
def _configure_database_url() -> str:
|
||||
settings = get_settings()
|
||||
settings = config.attributes.get("portfoliohub_settings") or get_settings()
|
||||
database_url = settings.active_database_url
|
||||
config.set_main_option("sqlalchemy.url", database_url.replace("%", "%%"))
|
||||
return database_url
|
||||
|
||||
@@ -18,7 +18,9 @@ depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column("portfolio_ledger", sa.Column("ledger_entry_id", sa.BigInteger(), sa.Identity(always=False), nullable=True))
|
||||
# PostgreSQL identity columns are implicitly NOT NULL. ``nullable=True``
|
||||
# renders a conflicting trailing ``NULL`` clause on a real PostgreSQL DB.
|
||||
op.add_column("portfolio_ledger", sa.Column("ledger_entry_id", sa.BigInteger(), sa.Identity(always=False), nullable=False))
|
||||
op.add_column("portfolio_ledger", sa.Column("order_id", sa.Text(), nullable=True))
|
||||
op.add_column("portfolio_ledger", sa.Column("execution_id", sa.Text(), nullable=True))
|
||||
op.add_column("portfolio_ledger", sa.Column("side", sa.Text(), nullable=True))
|
||||
|
||||
Reference in New Issue
Block a user