Skip to content

Commit

Permalink
refactor(prices): New price.updated field (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 18, 2024
1 parent e36e543 commit 3232ed4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Add Price updated field
Revision ID: 818f9ced20cd
Revises: 58a287bcd336
Create Date: 2024-06-16 11:57:37.751165
"""
from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "818f9ced20cd"
down_revision: Union[str, None] = "58a287bcd336"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"prices", sa.Column("updated", sa.DateTime(timezone=True), nullable=True)
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("prices", "updated")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@ class Price(Base):
source = mapped_column(String, nullable=True)

created = mapped_column(DateTime(timezone=True), server_default=func.now())
updated = mapped_column(DateTime(timezone=True), onupdate=func.now())

__tablename__ = "prices"
5 changes: 4 additions & 1 deletion app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ class PriceFull(PriceCreate):
# examples=["web app", "mobile app"],
# default=None,
# )
created: datetime.datetime
created: datetime.datetime = Field(description="datetime of the creation.")
updated: datetime.datetime | None = Field(
description="datetime of the last update.", default=None
)


class PriceFullWithRelations(PriceFull):
Expand Down

0 comments on commit 3232ed4

Please sign in to comment.