Skip to content

Commit

Permalink
refactor(proofs): New Proof.updated field (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored Jun 18, 2024
1 parent f1a15fe commit e36e543
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Add Proof updated field
Revision ID: 58a287bcd336
Revises: 8ec02f1af257
Create Date: 2024-06-16 11:51:21.584794
"""
from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "58a287bcd336"
down_revision: Union[str, None] = "8ec02f1af257"
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(
"proofs", 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("proofs", "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 @@ -131,6 +131,7 @@ class Proof(Base):
created = mapped_column(
DateTime(timezone=True), server_default=func.now(), index=True
)
updated = mapped_column(DateTime(timezone=True), onupdate=func.now())

__tablename__ = "proofs"

Expand Down
5 changes: 4 additions & 1 deletion app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ class ProofFull(BaseModel):
# 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 ProofBasicUpdatableFields(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,10 @@ def test_get_proofs(db_session, user_session: SessionModel, clean_proofs):
"file_path",
"mimetype",
"type",
"price_count",
"owner",
"created",
"price_count",
"updated",
}

for i, item in enumerate(data):
Expand Down

0 comments on commit e36e543

Please sign in to comment.