|
| 1 | +"""Add crew, props and scenery tables and allocations |
| 2 | +
|
| 3 | +Revision ID: fa27b233d26c |
| 4 | +Revises: 01fb1d6c6b08 |
| 5 | +Create Date: 2026-01-14 00:38:40.210710 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from typing import Sequence, Union |
| 10 | + |
| 11 | +import sqlalchemy as sa |
| 12 | +from alembic import op |
| 13 | + |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision: str = "fa27b233d26c" |
| 17 | +down_revision: Union[str, None] = "01fb1d6c6b08" |
| 18 | +branch_labels: Union[str, Sequence[str], None] = None |
| 19 | +depends_on: Union[str, Sequence[str], None] = None |
| 20 | + |
| 21 | + |
| 22 | +def upgrade() -> None: |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.create_table( |
| 25 | + "crew", |
| 26 | + sa.Column("id", sa.Integer(), nullable=False), |
| 27 | + sa.Column("show_id", sa.Integer(), nullable=False), |
| 28 | + sa.Column("first_name", sa.String(), nullable=True), |
| 29 | + sa.Column("last_name", sa.String(), nullable=True), |
| 30 | + sa.ForeignKeyConstraint( |
| 31 | + ["show_id"], ["shows.id"], name=op.f("fk_crew_show_id_shows") |
| 32 | + ), |
| 33 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_crew")), |
| 34 | + ) |
| 35 | + op.create_table( |
| 36 | + "props", |
| 37 | + sa.Column("id", sa.Integer(), nullable=False), |
| 38 | + sa.Column("show_id", sa.Integer(), nullable=False), |
| 39 | + sa.Column("name", sa.String(), nullable=True), |
| 40 | + sa.Column("description", sa.String(), nullable=True), |
| 41 | + sa.ForeignKeyConstraint( |
| 42 | + ["show_id"], ["shows.id"], name=op.f("fk_props_show_id_shows") |
| 43 | + ), |
| 44 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_props")), |
| 45 | + ) |
| 46 | + op.create_table( |
| 47 | + "scenery", |
| 48 | + sa.Column("id", sa.Integer(), nullable=False), |
| 49 | + sa.Column("show_id", sa.Integer(), nullable=False), |
| 50 | + sa.Column("name", sa.String(), nullable=True), |
| 51 | + sa.Column("description", sa.String(), nullable=True), |
| 52 | + sa.ForeignKeyConstraint( |
| 53 | + ["show_id"], ["shows.id"], name=op.f("fk_scenery_show_id_shows") |
| 54 | + ), |
| 55 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_scenery")), |
| 56 | + ) |
| 57 | + op.create_table( |
| 58 | + "props_allocation", |
| 59 | + sa.Column("id", sa.Integer(), nullable=False), |
| 60 | + sa.Column("props_id", sa.Integer(), nullable=False), |
| 61 | + sa.Column("scene_id", sa.Integer(), nullable=False), |
| 62 | + sa.ForeignKeyConstraint( |
| 63 | + ["props_id"], |
| 64 | + ["props.id"], |
| 65 | + name=op.f("fk_props_allocation_props_id_props"), |
| 66 | + ondelete="CASCADE", |
| 67 | + ), |
| 68 | + sa.ForeignKeyConstraint( |
| 69 | + ["scene_id"], |
| 70 | + ["scene.id"], |
| 71 | + name=op.f("fk_props_allocation_scene_id_scene"), |
| 72 | + ondelete="CASCADE", |
| 73 | + ), |
| 74 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_props_allocation")), |
| 75 | + ) |
| 76 | + op.create_table( |
| 77 | + "scenery_allocation", |
| 78 | + sa.Column("id", sa.Integer(), nullable=False), |
| 79 | + sa.Column("scenery_id", sa.Integer(), nullable=False), |
| 80 | + sa.Column("scene_id", sa.Integer(), nullable=False), |
| 81 | + sa.ForeignKeyConstraint( |
| 82 | + ["scene_id"], |
| 83 | + ["scene.id"], |
| 84 | + name=op.f("fk_scenery_allocation_scene_id_scene"), |
| 85 | + ondelete="CASCADE", |
| 86 | + ), |
| 87 | + sa.ForeignKeyConstraint( |
| 88 | + ["scenery_id"], |
| 89 | + ["scenery.id"], |
| 90 | + name=op.f("fk_scenery_allocation_scenery_id_scenery"), |
| 91 | + ondelete="CASCADE", |
| 92 | + ), |
| 93 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_scenery_allocation")), |
| 94 | + ) |
| 95 | + # ### end Alembic commands ### |
| 96 | + |
| 97 | + |
| 98 | +def downgrade() -> None: |
| 99 | + # ### commands auto generated by Alembic - please adjust! ### |
| 100 | + op.drop_table("scenery_allocation") |
| 101 | + op.drop_table("props_allocation") |
| 102 | + op.drop_table("scenery") |
| 103 | + op.drop_table("props") |
| 104 | + op.drop_table("crew") |
| 105 | + # ### end Alembic commands ### |
0 commit comments