-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(proofs): New proof.date field (#330)
Co-authored-by: Raphaël Bournhonesque <[email protected]>
- Loading branch information
1 parent
3232ed4
commit 1b41308
Showing
6 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
alembic/versions/20240617_1359_5f5835d81917_add_proof_date_field.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Add Proof date field | ||
Revision ID: 5f5835d81917 | ||
Revises: 818f9ced20cd | ||
Create Date: 2024-06-17 13:59:42.294690 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "5f5835d81917" | ||
down_revision: Union[str, None] = "818f9ced20cd" | ||
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("date", sa.Date(), nullable=True)) | ||
# Set the date to the date of the first price for each proof | ||
op.execute( | ||
""" | ||
UPDATE proofs | ||
SET date = ( | ||
SELECT date | ||
FROM prices | ||
WHERE prices.proof_id = proofs.id | ||
LIMIT 1 | ||
) | ||
WHERE type IN ('PRICE_TAG', 'RECEIPT') | ||
""" | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("proofs", "date") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters