This commit is contained in:
2026-07-27 15:54:25 +08:00
parent a8c0e1af3d
commit cf6d708566
12 changed files with 241 additions and 869 deletions
@@ -0,0 +1,38 @@
"""add product_id to stp_files
Revision ID: 006c18c51b0d
Revises: 9928d7f8c1ef
Create Date: 2026-07-23 10:37:56.516787
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '006c18c51b0d'
down_revision: Union[str, Sequence[str], None] = '9928d7f8c1ef'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema: stp_files 加 product_id 外键,关联进销存成品。"""
op.add_column("stp_files", sa.Column("product_id", sa.Integer(), nullable=True))
op.create_index("ix_stp_files_product_id", "stp_files", ["product_id"])
op.create_foreign_key(
"fk_stp_files_product_id_products",
"stp_files",
"products",
["product_id"],
["id"],
)
def downgrade() -> None:
"""Downgrade schema."""
op.drop_constraint("fk_stp_files_product_id_products", "stp_files", type_="foreignkey")
op.drop_index("ix_stp_files_product_id", table_name="stp_files")
op.drop_column("stp_files", "product_id")