fix: handle Alembic offline mode in migration _column_exists() helper
CI/CD Pipeline / Build Production Runtime Images (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Failing after 52h57m33s
CI/CD Pipeline / Deploy Staging (push) Failing after 52h58m54s
CI/CD Pipeline / Frontend Lint (push) Failing after 53h0m13s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 53h0m59s

The _column_exists() helper in migrations 026-029 calls conn.execute()
which returns None in Alembic's offline/SQL mode (--sql flag), causing
AttributeError on result.scalar(). Add context.is_offline_mode() guard
to skip the idempotency check in offline mode and unconditionally emit
the DDL statements.

Fixes: Validate CI step 'alembic upgrade head --sql' failure.
This commit is contained in:
灵应
2026-07-07 07:53:27 +08:00
parent 6a853fef3c
commit 653be7755b
4 changed files with 12 additions and 4 deletions
@@ -10,7 +10,7 @@ Create Date: 2026-07-05
import sqlalchemy as sa
from alembic import op
from alembic import context, op
revision = "026"
down_revision = "025"
@@ -19,6 +19,8 @@ depends_on = None
def _column_exists(table: str, column: str) -> bool:
if context.is_offline_mode():
return False
conn = op.get_bind()
result = conn.execute(
sa.text(
+3 -1
View File
@@ -10,7 +10,7 @@ Create Date: 2026-07-05
import sqlalchemy as sa
from alembic import op
from alembic import context, op
revision = "027"
down_revision = "026"
@@ -19,6 +19,8 @@ depends_on = None
def _column_exists(table: str, column: str) -> bool:
if context.is_offline_mode():
return False
conn = op.get_bind()
result = conn.execute(
sa.text(
@@ -10,7 +10,7 @@ Create Date: 2026-07-05
import sqlalchemy as sa
from alembic import op
from alembic import context, op
revision = "028"
down_revision = "027"
@@ -19,6 +19,8 @@ depends_on = None
def _column_exists(table: str, column: str) -> bool:
if context.is_offline_mode():
return False
conn = op.get_bind()
result = conn.execute(
sa.text(
+3 -1
View File
@@ -10,7 +10,7 @@ Create Date: 2026-07-05
import sqlalchemy as sa
from alembic import op
from alembic import context, op
revision = "029"
down_revision = "028"
@@ -19,6 +19,8 @@ depends_on = None
def _column_exists(table: str, column: str) -> bool:
if context.is_offline_mode():
return False
conn = op.get_bind()
result = conn.execute(
sa.text(