Skip to content

Commit

Permalink
change gtfs_ride_stop_id to bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Dec 3, 2023
1 parent ad47124 commit 39d4aa3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""change_gtfs_ride_stop_id_to_bigint
Revision ID: a851bbd0b02d
Revises: 7e9880e6fcf6
Create Date: 2023-12-03 06:46:20.529519+00:00
"""
from alembic import op
import sqlalchemy as sa


import open_bus_stride_db


# revision identifiers, used by Alembic.
revision = 'a851bbd0b02d'
down_revision = '7e9880e6fcf6'
branch_labels = None
depends_on = None


def upgrade():
op.alter_column('gtfs_ride', 'first_gtfs_ride_stop_id', existing_type=sa.Integer, type_=sa.BigInteger)
op.alter_column('gtfs_ride', 'last_gtfs_ride_stop_id', existing_type=sa.Integer, type_=sa.BigInteger)
op.alter_column('gtfs_ride_stop', 'id', existing_type=sa.Integer, type_=sa.BigInteger)
op.execute('ALTER SEQUENCE gtfs_ride_stop_id_seq AS BIGINT')
op.execute('SELECT setval(\'gtfs_ride_stop_id_seq\', 2147483648)')


def downgrade():
raise Exception('Cannot downgrade')
4 changes: 2 additions & 2 deletions open_bus_stride_db/model/gtfs_ride.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class GtfsRide(Base):
primaryjoin="GtfsRide.id==GtfsRideStop.gtfs_ride_id"
)
first_gtfs_ride_stop_id = sqlalchemy.Column(
sqlalchemy.Integer, sqlalchemy.ForeignKey('gtfs_ride_stop.id'),
sqlalchemy.BigInteger, sqlalchemy.ForeignKey('gtfs_ride_stop.id'),
**info("""
The first [[gtfs_ride_stop]] along this ride.
Populated from [[stride-etl-gtfs-update-ride-aggregations]].
""")
)
last_gtfs_ride_stop_id = sqlalchemy.Column(
sqlalchemy.Integer, sqlalchemy.ForeignKey('gtfs_ride_stop.id'),
sqlalchemy.BigInteger, sqlalchemy.ForeignKey('gtfs_ride_stop.id'),
**info("""
The last [[gtfs_ride_stop]] along this ride.
Populated from [[stride-etl-gtfs-update-ride-aggregations]].
Expand Down
2 changes: 1 addition & 1 deletion open_bus_stride_db/model/gtfs_ride_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GtfsRideStop(Base):
""")},
)

id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
id = sqlalchemy.Column(sqlalchemy.BigInteger, primary_key=True)
gtfs_stop_id = sqlalchemy.Column(
sqlalchemy.Integer, sqlalchemy.ForeignKey('gtfs_stop.id'), index=True,
**info("The related [[gtfs_stop]].")
Expand Down

0 comments on commit 39d4aa3

Please sign in to comment.