feat(shipping-notice): 新增库存快照管理与RPA批量导出功能
This commit is contained in:
1 parent
fc694a8f43
commit
d54f51ddc3
48 files changed
+4970
-543
No files matched your search
+84
@@ -0,0 +1,84 @@
|
||||
"""Add shipping inventory snapshot source and audit fields.
|
||||
|
||||
Purpose:
|
||||
Support warehouse-level inventory snapshots, TTL reuse, scheduled RPA runs,
|
||||
and task-to-snapshot audit links.
|
||||
Dependencies:
|
||||
Alembic revision b3c4d5e6f7a8.
|
||||
Flow:
|
||||
RPA batch callback writes source_code/warehouse_id/expires_at on
|
||||
shipping_inventory_files; task links record reuse reason and age.
|
||||
|
||||
Revision ID: a8b9c0d1e2f3
|
||||
Revises: b3c4d5e6f7a8
|
||||
Create Date: 2026-07-07 19:30:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "a8b9c0d1e2f3"
|
||||
down_revision = "b3c4d5e6f7a8"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
"""Add inventory snapshot source metadata and link audit columns."""
|
||||
with op.batch_alter_table("shipping_inventory_files", schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column("warehouse_id", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("warehouse_code", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("source_code", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("source_type", sa.String(length=32), nullable=True))
|
||||
batch_op.add_column(sa.Column("snapshot_status", sa.String(length=32), nullable=True))
|
||||
batch_op.add_column(sa.Column("exported_at", sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column("expires_at", sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column("rpa_run_no", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("schedule_run_id", sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column("source_query_json", sa.JSON(), nullable=True))
|
||||
batch_op.create_index("ix_shipping_inventory_files_warehouse_id", ["warehouse_id"], unique=False)
|
||||
batch_op.create_index("ix_shipping_inventory_files_source_code", ["source_code"], unique=False)
|
||||
batch_op.create_index("ix_shipping_inventory_files_snapshot_status", ["snapshot_status"], unique=False)
|
||||
batch_op.create_index("ix_shipping_inventory_files_exported_at", ["exported_at"], unique=False)
|
||||
batch_op.create_index("ix_shipping_inventory_files_expires_at", ["expires_at"], unique=False)
|
||||
batch_op.create_index("ix_shipping_inventory_files_schedule_run_id", ["schedule_run_id"], unique=False)
|
||||
batch_op.create_index(
|
||||
"ix_shipping_inventory_files_source_snapshot",
|
||||
["source_code", "warehouse_id", "snapshot_status", "exported_at"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
with op.batch_alter_table("shipping_task_inventory_links", schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column("link_reason", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("matched_warehouse_id", sa.String(length=64), nullable=True))
|
||||
batch_op.add_column(sa.Column("snapshot_age_seconds", sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column("audit_payload_json", sa.JSON(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
"""Remove inventory snapshot source metadata and link audit columns."""
|
||||
with op.batch_alter_table("shipping_task_inventory_links", schema=None) as batch_op:
|
||||
batch_op.drop_column("audit_payload_json")
|
||||
batch_op.drop_column("snapshot_age_seconds")
|
||||
batch_op.drop_column("matched_warehouse_id")
|
||||
batch_op.drop_column("link_reason")
|
||||
|
||||
with op.batch_alter_table("shipping_inventory_files", schema=None) as batch_op:
|
||||
batch_op.drop_index("ix_shipping_inventory_files_source_snapshot")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_schedule_run_id")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_expires_at")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_exported_at")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_snapshot_status")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_source_code")
|
||||
batch_op.drop_index("ix_shipping_inventory_files_warehouse_id")
|
||||
batch_op.drop_column("source_query_json")
|
||||
batch_op.drop_column("schedule_run_id")
|
||||
batch_op.drop_column("rpa_run_no")
|
||||
batch_op.drop_column("expires_at")
|
||||
batch_op.drop_column("exported_at")
|
||||
batch_op.drop_column("snapshot_status")
|
||||
batch_op.drop_column("source_type")
|
||||
batch_op.drop_column("source_code")
|
||||
batch_op.drop_column("warehouse_code")
|
||||
batch_op.drop_column("warehouse_id")
|
||||
Reference in new issue
Block a user