From a16a3e0dc182e61d04ad09476506eecf4909e1a4 Mon Sep 17 00:00:00 2001 From: ori Date: Thu, 24 Oct 2024 20:23:14 +0300 Subject: [PATCH] change siri_ride_stop_id to bigint --- ...471_change_siri_ride_stop_id_to_big_int.py | 30 +++++++++++++++++++ open_bus_stride_db/model/siri_ride_stop.py | 2 +- .../model/siri_vehicle_location.py | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 alembic/versions/eb501cf9f471_change_siri_ride_stop_id_to_big_int.py diff --git a/alembic/versions/eb501cf9f471_change_siri_ride_stop_id_to_big_int.py b/alembic/versions/eb501cf9f471_change_siri_ride_stop_id_to_big_int.py new file mode 100644 index 0000000..1b55026 --- /dev/null +++ b/alembic/versions/eb501cf9f471_change_siri_ride_stop_id_to_big_int.py @@ -0,0 +1,30 @@ +"""change siri_ride_stop_id to big int + +Revision ID: eb501cf9f471 +Revises: a851bbd0b02d +Create Date: 2024-10-24 17:16:40.993722+00:00 + +""" +from alembic import op +import sqlalchemy as sa + + +import open_bus_stride_db + + +# revision identifiers, used by Alembic. +revision = 'eb501cf9f471' +down_revision = 'a851bbd0b02d' +branch_labels = None +depends_on = None + + +def upgrade(): + op.alter_column('siri_vehicle_location', 'siri_ride_stop_id', existing_type=sa.Integer, type_=sa.BigInteger) + op.alter_column('siri_ride_stop', 'id', existing_type=sa.Integer, type_=sa.BigInteger) + op.execute('ALTER SEQUENCE siri_ride_stop_id_seq AS BIGINT') + op.execute('SELECT setval(\'siri_ride_stop_id_seq\', 2147483431)') + + +def downgrade(): + raise Exception('Cannot downgrade') diff --git a/open_bus_stride_db/model/siri_ride_stop.py b/open_bus_stride_db/model/siri_ride_stop.py index cf0bded..8d6783b 100644 --- a/open_bus_stride_db/model/siri_ride_stop.py +++ b/open_bus_stride_db/model/siri_ride_stop.py @@ -16,7 +16,7 @@ class SiriRideStop(Base): Populated in near real time from the SIRI data by [[siri-etl-process-snapshot-new-snapshots-daemon]]. """)} ) - id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) + id = sqlalchemy.Column(sqlalchemy.BigInteger, primary_key=True) siri_stop_id = sqlalchemy.Column( sqlalchemy.Integer, sqlalchemy.ForeignKey('siri_stop.id'), index=True, **info("The related [[siri_stop]].") diff --git a/open_bus_stride_db/model/siri_vehicle_location.py b/open_bus_stride_db/model/siri_vehicle_location.py index cfdd801..f65be00 100644 --- a/open_bus_stride_db/model/siri_vehicle_location.py +++ b/open_bus_stride_db/model/siri_vehicle_location.py @@ -20,7 +20,7 @@ class SiriVehicleLocation(Base): foreign_keys=[siri_snapshot_id] ) siri_ride_stop_id = sqlalchemy.Column( - sqlalchemy.Integer, sqlalchemy.ForeignKey('siri_ride_stop.id'), index=True, + sqlalchemy.BigInteger, sqlalchemy.ForeignKey('siri_ride_stop.id'), index=True, **info(""" The [[siri_ride_stop]] which is nearest to this vehicle location. This relation can be used to get all relevant details like route / ride / stop relating to this location.