Skip to content

Commit

Permalink
change siri_ride_stop_id to bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Oct 24, 2024
1 parent 2c3d54f commit a16a3e0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 1 addition & 1 deletion open_bus_stride_db/model/siri_ride_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]].")
Expand Down
2 changes: 1 addition & 1 deletion open_bus_stride_db/model/siri_vehicle_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a16a3e0

Please sign in to comment.