Skip to content

Commit

Permalink
Merge pull request #221 from ParkenDD/allow-realtime-opening-status-null
Browse files Browse the repository at this point in the history
Allow Realtime Opening Status Null
  • Loading branch information
the-infinity authored Nov 20, 2024
2 parents fe93f69 + 170f3f9 commit c0061fb
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""allow realtime opening status null
Revision ID: 4f09ed999210
Revises: 95992608c5d1
Create Date: 2024-11-20 09:06:51.525217
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '4f09ed999210'
down_revision = '95992608c5d1'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('parking_site', schema=None) as batch_op:
batch_op.alter_column(
'realtime_opening_status',
existing_type=postgresql.ENUM('OPEN', 'CLOSED', 'UNKNOWN', name='openingstatus'),
nullable=True,
)

with op.batch_alter_table('parking_site_history', schema=None) as batch_op:
batch_op.alter_column(
'realtime_opening_status',
existing_type=postgresql.ENUM('OPEN', 'CLOSED', 'UNKNOWN', name='history_openingstatus'),
type_=sa.Enum('OPEN', 'CLOSED', 'UNKNOWN', name='history_openingstatus'),
nullable=True,
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('parking_site_history', schema=None) as batch_op:
batch_op.alter_column(
'realtime_opening_status',
existing_type=sa.Enum('OPEN', 'CLOSED', 'UNKNOWN', name='history_openingstatus'),
type_=postgresql.ENUM('OPEN', 'CLOSED', 'UNKNOWN', name='history_openingstatus'),
nullable=False,
)

with op.batch_alter_table('parking_site', schema=None) as batch_op:
batch_op.alter_column(
'realtime_opening_status',
existing_type=postgresql.ENUM('OPEN', 'CLOSED', 'UNKNOWN', name='openingstatus'),
nullable=False,
)

# ### end Alembic commands ###
6 changes: 4 additions & 2 deletions webapp/models/parking_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ class ParkingSite(BaseModel):
has_realtime_data: Mapped[Optional[bool]] = mapped_column(Boolean(), nullable=False, default=False)
static_data_updated_at: Mapped[Optional[datetime]] = mapped_column(UtcDateTime(), nullable=True)
realtime_data_updated_at: Mapped[Optional[datetime]] = mapped_column(UtcDateTime(), nullable=True)
realtime_opening_status: Mapped[OpeningStatus] = mapped_column(
SqlalchemyEnum(OpeningStatus), nullable=False, default=OpeningStatus.UNKNOWN
realtime_opening_status: Mapped[OpeningStatus | None] = mapped_column(
SqlalchemyEnum(OpeningStatus),
nullable=True,
default=None,
)

lat: Mapped[Decimal] = mapped_column(Numeric(precision=10, scale=7), nullable=False)
Expand Down
4 changes: 2 additions & 2 deletions webapp/models/parking_site_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ParkingSiteHistory(BaseModel):

static_data_updated_at: Mapped[Optional[datetime]] = mapped_column(UtcDateTime(), nullable=True)
realtime_data_updated_at: Mapped[Optional[datetime]] = mapped_column(UtcDateTime(), nullable=True)
realtime_opening_status: Mapped[OpeningStatus] = mapped_column(
SqlalchemyEnum(OpeningStatus), nullable=False, default=OpeningStatus.UNKNOWN
realtime_opening_status: Mapped[OpeningStatus | None] = mapped_column(
SqlalchemyEnum(OpeningStatus), nullable=True, default=None
)

capacity: Mapped[Optional[int]] = mapped_column(Integer(), nullable=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
'realtime_opening_status': EnumField(
enum=OpeningStatus,
required=False,
nullable=True,
description='Realtime opening status which is reported by the client.',
),
'lat': DecimalField(precision=10, scale=7),
Expand Down

0 comments on commit c0061fb

Please sign in to comment.