-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add price.price_per field (#127)
- Loading branch information
1 parent
27b7f0f
commit 5740271
Showing
5 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
alembic/versions/20240111_0914_a8ad2f078f3f_add_product_price_per_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,40 @@ | ||
"""add product.price_per field | ||
Revision ID: a8ad2f078f3f | ||
Revises: 007443669adc | ||
Create Date: 2024-01-11 09:14:25.778905 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "a8ad2f078f3f" | ||
down_revision: Union[str, None] = "007443669adc" | ||
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( | ||
"price_per", | ||
sa.String(length=255), | ||
nullable=True, | ||
), | ||
) | ||
op.execute( | ||
"UPDATE prices SET price_per = 'KILOGRAM' WHERE price_per IS NULL AND category_tag IS NOT NULL;" | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("prices", "price_per") | ||
# ### 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