-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
129 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...mp_py/migrations/versions/performance_manager_dev/008_32ba735d080c_add_revenue_columns.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"""add revenue columns | ||
Revision ID: 32ba735d080c | ||
Revises: 896dedd8a4db | ||
Create Date: 2024-09-20 08:47:52.784591 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from lamp_py.postgres.rail_performance_manager_schema import ( | ||
TempEventCompare, | ||
VehicleTrips, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "32ba735d080c" | ||
down_revision = "896dedd8a4db" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.execute( | ||
f"ALTER TABLE public.vehicle_trips DISABLE TRIGGER rt_trips_update_branch_trunk;" | ||
) | ||
op.execute( | ||
f"ALTER TABLE public.vehicle_trips DISABLE TRIGGER update_vehicle_trips_modified;" | ||
) | ||
op.drop_index("ix_vehicle_trips_composite_1", table_name="vehicle_trips") | ||
op.drop_constraint("vehicle_trips_unique_trip", table_name="vehicle_trips") | ||
|
||
op.add_column( | ||
"temp_event_compare", sa.Column("revenue", sa.Boolean(), nullable=True) | ||
) | ||
op.add_column( | ||
"vehicle_trips", sa.Column("revenue", sa.Boolean(), nullable=True) | ||
) | ||
op.execute(sa.update(TempEventCompare).values(revenue=True)) | ||
op.execute(sa.update(VehicleTrips).values(revenue=True)) | ||
op.alter_column("temp_event_compare", "revenue", nullable=False) | ||
op.alter_column("vehicle_trips", "revenue", nullable=False) | ||
|
||
op.create_unique_constraint( | ||
"vehicle_trips_unique_trip", | ||
"vehicle_trips", | ||
["service_date", "route_id", "trip_id"], | ||
) | ||
op.create_index( | ||
"ix_vehicle_trips_composite_1", | ||
"vehicle_trips", | ||
["route_id", "direction_id", "vehicle_id"], | ||
unique=False, | ||
) | ||
op.execute( | ||
f"ALTER TABLE public.vehicle_trips ENABLE TRIGGER rt_trips_update_branch_trunk;" | ||
) | ||
op.execute( | ||
f"ALTER TABLE public.vehicle_trips ENABLE TRIGGER update_vehicle_trips_modified;" | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("vehicle_trips", "revenue") | ||
op.drop_column("temp_event_compare", "revenue") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.