2026-05-31 21:35:09 +00:00
|
|
|
"""add_project_equipment_and_crew
|
|
|
|
|
|
|
|
|
|
Revision ID: b183c967088f
|
|
|
|
|
Revises: cfe638817921
|
|
|
|
|
Create Date: 2026-05-31 21:32:46.068246
|
|
|
|
|
|
|
|
|
|
"""
|
2026-06-10 21:31:41 +00:00
|
|
|
|
2026-05-31 21:35:09 +00:00
|
|
|
from typing import Sequence, Union
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
2026-06-10 21:31:41 +00:00
|
|
|
revision: str = "b183c967088f"
|
|
|
|
|
down_revision: Union[str, None] = "cfe638817921"
|
2026-05-31 21:35:09 +00:00
|
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
|
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
2026-06-10 21:31:41 +00:00
|
|
|
op.create_table(
|
|
|
|
|
"project_equipment_groups",
|
|
|
|
|
sa.Column("id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("name", sa.String(length=255), nullable=False),
|
|
|
|
|
sa.Column("project_id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("sort_order", sa.Integer(), nullable=False),
|
|
|
|
|
sa.Column("start_date", sa.DateTime(timezone=True), nullable=True),
|
|
|
|
|
sa.Column("end_date", sa.DateTime(timezone=True), nullable=True),
|
|
|
|
|
sa.ForeignKeyConstraint(["project_id"], ["projects.id"], ondelete="CASCADE"),
|
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
2026-05-31 21:35:09 +00:00
|
|
|
)
|
2026-06-10 21:31:41 +00:00
|
|
|
op.create_table(
|
|
|
|
|
"project_equipment",
|
|
|
|
|
sa.Column("id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("project_equipment_group_id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("equipment_id", sa.String(length=36), nullable=True),
|
|
|
|
|
sa.Column("name", sa.String(length=255), nullable=False),
|
|
|
|
|
sa.Column("quantity", sa.Float(), nullable=False),
|
|
|
|
|
sa.Column("price", sa.Float(), nullable=False),
|
|
|
|
|
sa.Column("discount", sa.Float(), nullable=False),
|
|
|
|
|
sa.Column("sort_order", sa.Integer(), nullable=False),
|
|
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
|
["equipment_id"], ["equipment.id"], ondelete="SET NULL"
|
|
|
|
|
),
|
|
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
|
["project_equipment_group_id"],
|
|
|
|
|
["project_equipment_groups.id"],
|
|
|
|
|
ondelete="CASCADE",
|
|
|
|
|
),
|
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
2026-05-31 21:35:09 +00:00
|
|
|
)
|
2026-06-10 21:31:41 +00:00
|
|
|
op.create_table(
|
|
|
|
|
"project_crew",
|
|
|
|
|
sa.Column("id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("project_function_id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("crew_id", sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column("start_date", sa.DateTime(timezone=True), nullable=True),
|
|
|
|
|
sa.Column("end_date", sa.DateTime(timezone=True), nullable=True),
|
|
|
|
|
sa.Column("notes", sa.Text(), nullable=True),
|
|
|
|
|
sa.ForeignKeyConstraint(["crew_id"], ["crew.id"], ondelete="CASCADE"),
|
|
|
|
|
sa.ForeignKeyConstraint(
|
|
|
|
|
["project_function_id"], ["project_functions.id"], ondelete="CASCADE"
|
|
|
|
|
),
|
|
|
|
|
sa.PrimaryKeyConstraint("id"),
|
2026-05-31 21:35:09 +00:00
|
|
|
)
|
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
2026-06-10 21:31:41 +00:00
|
|
|
op.drop_table("project_crew")
|
|
|
|
|
op.drop_table("project_equipment")
|
|
|
|
|
op.drop_table("project_equipment_groups")
|
2026-05-31 21:35:09 +00:00
|
|
|
# ### end Alembic commands ###
|