35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""sales and stock statement rows belong to the MR who entered them
|
|
|
|
Same change as Sales Projection: rows with no owner stay as the shared product list.
|
|
|
|
Revision ID: x4b0d6f2a9c1
|
|
Revises: w3a9c5e1f8b0
|
|
Create Date: 2026-10-27
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision: str = "x4b0d6f2a9c1"
|
|
down_revision: str | None = "w3a9c5e1f8b0"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("sales_and_stock_statement", sa.Column("owner_user_id", sa.UUID(), nullable=True))
|
|
op.create_foreign_key(
|
|
"fk_sales_stock_owner", "sales_and_stock_statement", "user", ["owner_user_id"], ["id"],
|
|
ondelete="RESTRICT",
|
|
)
|
|
op.create_index("ix_sales_stock_owner", "sales_and_stock_statement", ["owner_user_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_sales_stock_owner", table_name="sales_and_stock_statement")
|
|
op.drop_constraint("fk_sales_stock_owner", "sales_and_stock_statement", type_="foreignkey")
|
|
op.drop_column("sales_and_stock_statement", "owner_user_id")
|