18 lines
1.1 KiB
Python
18 lines
1.1 KiB
Python
"""分配调整的原台账与业务分管归属。"""
|
|||
|
|
from alembic import op
|
||
|
|
revision: str = "19d0e1f2a3b4"
|
||
|
|
down_revision: str | None = "18c9d0e1f2a3"
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
def upgrade():
|
||
|
|
op.execute("ALTER TABLE adjustment_orders ADD COLUMN adjustment_type VARCHAR(32) NOT NULL DEFAULT 'GENERAL' COMMENT '调整类型:GENERAL普通 ALLOCATION分配差额'")
|
||
|
|
op.execute("ALTER TABLE adjustment_orders ADD COLUMN source_ledger_id BIGINT UNSIGNED NULL COMMENT '分配差额对应的原台账ID'")
|
||
|
|
op.execute("ALTER TABLE adjustment_orders ADD COLUMN attribution_json JSON NULL COMMENT '原台账业务与分管归属快照'")
|
||
|
|
|
||
|
|
def downgrade():
|
||
|
|
if op.get_bind().exec_driver_sql("SELECT COUNT(*) FROM adjustment_orders WHERE source_ledger_id IS NOT NULL").scalar():
|
||
|
|
raise RuntimeError("已有分配调整依据,拒绝删除归属信息;请使用应用版本回退")
|
||
|
|
op.drop_column("adjustment_orders", "attribution_json")
|
||
|
|
op.drop_column("adjustment_orders", "source_ledger_id")
|
||
|
|
op.drop_column("adjustment_orders", "adjustment_type")
|