mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 02:00:46 +08:00
Add alembic revision for biz_state_task.collect_queued_at.
Fixes /v1/biz-state/tasks 500 when ORM expects the column but DB was still on prior head. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3a0de0d7fb
commit
305822aa4f
1 changed files with 51 additions and 0 deletions
51
alembic/versions/20260922_biz_state_queued.py
Normal file
51
alembic/versions/20260922_biz_state_queued.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"""Add biz_state_task.collect_queued_at for collect queue claim.
|
||||
|
||||
Revision ID: 20260922_biz_state_queued
|
||||
Revises: 20260921_exec_policy
|
||||
Create Date: 2026-09-22
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20260922_biz_state_queued"
|
||||
down_revision: Union[str, Sequence[str], None] = "20260921_exec_policy"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
dialect = str(getattr(bind.dialect, "name", "") or "").lower()
|
||||
if dialect.startswith("postgres"):
|
||||
op.execute(
|
||||
"ALTER TABLE biz_state_task ADD COLUMN IF NOT EXISTS collect_queued_at TIMESTAMP"
|
||||
)
|
||||
else:
|
||||
# SQLite / others: best-effort
|
||||
try:
|
||||
op.add_column(
|
||||
"biz_state_task",
|
||||
__import__("sqlalchemy", fromlist=["Column"]).Column(
|
||||
"collect_queued_at",
|
||||
__import__("sqlalchemy", fromlist=["DateTime"]).DateTime(),
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
dialect = str(getattr(bind.dialect, "name", "") or "").lower()
|
||||
if dialect.startswith("postgres"):
|
||||
op.execute("ALTER TABLE biz_state_task DROP COLUMN IF EXISTS collect_queued_at")
|
||||
else:
|
||||
try:
|
||||
op.drop_column("biz_state_task", "collect_queued_at")
|
||||
except Exception:
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue