-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename order status column (#3570) (minor)
### Changed - The is_delivered column in Order is renamed to is_open with values flipped.
- Loading branch information
Showing
13 changed files
with
90 additions
and
43 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
alembic/versions/2024_08_09_7770dcad8bde_rename_order_status.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,50 @@ | ||
"""Rename order status | ||
Revision ID: 7770dcad8bde | ||
Revises: bb4c6dbad991 | ||
Create Date: 2024-08-09 09:47:47.814700 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7770dcad8bde" | ||
down_revision = "bb4c6dbad991" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
class Base(DeclarativeBase): | ||
pass | ||
|
||
|
||
class Order(Base): | ||
__tablename__ = "order" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True) | ||
is_open: Mapped[str] | ||
|
||
|
||
def upgrade(): | ||
op.alter_column( | ||
table_name="order", column_name="is_delivered", type_=sa.Boolean, new_column_name="is_open" | ||
) | ||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
for order in session.query(Order).all(): | ||
order.is_open = not order.is_open | ||
session.commit() | ||
|
||
|
||
def downgrade(): | ||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
for order in session.query(Order).all(): | ||
order.is_open = not order.is_open | ||
session.commit() | ||
op.alter_column( | ||
table_name="order", new_column_name="is_delivered", type_=sa.Boolean, column_name="is_open" | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class OrderDeliveredUpdateRequest(BaseModel): | ||
class OrderOpenUpdateRequest(BaseModel): | ||
delivered_analyses_count: int = Field(..., alias="deliveredAnalysesCount") |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class OrderDeliveredPatch(BaseModel): | ||
delivered: bool | ||
class OrderOpenPatch(BaseModel): | ||
open: bool |
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
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