37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""sales projection rows belong to the MR who entered them
|
|
|
|
Until now the form was one shared sheet, so two MRs overwrote each other and the NAME /
|
|
HEADQUARTER columns had no reliable value. Rows with no owner stay as the shared product
|
|
list every MR starts from; an MR's first entry on a product becomes their own row.
|
|
|
|
Revision ID: u1e7a3c9d6f8
|
|
Revises: t0d6f2b8c5e7
|
|
Create Date: 2026-10-27
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision: str = "u1e7a3c9d6f8"
|
|
down_revision: str | None = "t0d6f2b8c5e7"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("sales_projection", sa.Column("owner_user_id", sa.UUID(), nullable=True))
|
|
op.create_foreign_key(
|
|
"fk_sales_projection_owner", "sales_projection", "user", ["owner_user_id"], ["id"],
|
|
ondelete="RESTRICT",
|
|
)
|
|
op.create_index("ix_sales_projection_owner", "sales_projection", ["owner_user_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_sales_projection_owner", table_name="sales_projection")
|
|
op.drop_constraint("fk_sales_projection_owner", "sales_projection", type_="foreignkey")
|
|
op.drop_column("sales_projection", "owner_user_id")
|