Update TripDay models: add date
This commit is contained in:
parent
501dea8e60
commit
20cf000020
33
backend/trip/alembic/versions/54aec61bc15d_tripday_date.py
Normal file
33
backend/trip/alembic/versions/54aec61bc15d_tripday_date.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"""TripDay date feature
|
||||||
|
|
||||||
|
Revision ID: 54aec61bc15d
|
||||||
|
Revises: b6d707f9c35a
|
||||||
|
Create Date: 2025-10-22 14:41:46.343276
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel.sql.sqltypes
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "54aec61bc15d"
|
||||||
|
down_revision = "b6d707f9c35a"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table("tripday", schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column("dt", sa.Date(), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table("tripday", schema=None) as batch_op:
|
||||||
|
batch_op.drop_column("dt")
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@ -455,10 +455,12 @@ class TripInvitationRead(TripReadBase):
|
|||||||
|
|
||||||
class TripDayBase(SQLModel):
|
class TripDayBase(SQLModel):
|
||||||
label: str
|
label: str
|
||||||
|
dt: date | None = None
|
||||||
|
|
||||||
|
|
||||||
class TripDay(TripDayBase, table=True):
|
class TripDay(TripDayBase, table=True):
|
||||||
id: int | None = Field(default=None, primary_key=True)
|
id: int | None = Field(default=None, primary_key=True)
|
||||||
|
|
||||||
trip_id: int = Field(foreign_key="trip.id", ondelete="CASCADE", index=True)
|
trip_id: int = Field(foreign_key="trip.id", ondelete="CASCADE", index=True)
|
||||||
trip: Trip | None = Relationship(back_populates="days")
|
trip: Trip | None = Relationship(back_populates="days")
|
||||||
|
|
||||||
@ -473,6 +475,7 @@ class TripDayRead(TripDayBase):
|
|||||||
def serialize(cls, obj: TripDay) -> "TripDayRead":
|
def serialize(cls, obj: TripDay) -> "TripDayRead":
|
||||||
return cls(
|
return cls(
|
||||||
id=obj.id,
|
id=obj.id,
|
||||||
|
dt=obj.dt,
|
||||||
label=obj.label,
|
label=obj.label,
|
||||||
items=[TripItemRead.serialize(item) for item in obj.items],
|
items=[TripItemRead.serialize(item) for item in obj.items],
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user