-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.10.0' into preview
- Loading branch information
Showing
14 changed files
with
278 additions
and
19 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
common/alembic/versions/90ff6ac09fe5_add_required_level_column.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,59 @@ | ||
"""Add required_level column | ||
Revision ID: 90ff6ac09fe5 | ||
Revises: a2df38682595 | ||
Create Date: 2024-01-22 12:31:38.823682 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '90ff6ac09fe5' | ||
down_revision = 'a2df38682595' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
old_enum = ("INIT", "VALIDATION_REQUEST", "VALID", "REFUNDED_BY_ADMIN", "INVALID", "REFUNDED_BY_BUYER", | ||
"PURCHASE_LIMIT_EXCEED", "TIME_LIMIT", "UNKNOWN") | ||
new_enum = sorted(old_enum + ("REQUIRED_LEVEL",)) | ||
|
||
old_status = sa.Enum(*old_enum, name="receiptstatus") | ||
new_status = sa.Enum(*new_enum, name="receiptstatus") | ||
tmp_status = sa.Enum(*new_enum, name="_receiptstatus") | ||
|
||
receipt_table = sa.sql.table( | ||
"receipt", | ||
sa.Column("status", new_status, nullable=False) | ||
) | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
tmp_status.create(op.get_bind(), checkfirst=False) | ||
op.execute("ALTER TABLE receipt ALTER COLUMN status TYPE _receiptstatus USING status::text::_receiptstatus") | ||
old_status.drop(op.get_bind(), checkfirst=False) | ||
new_status.create(op.get_bind(), checkfirst=False) | ||
op.execute("ALTER TABLE receipt ALTER COLUMN status TYPE receiptstatus USING status::text::receiptstatus") | ||
tmp_status.drop(op.get_bind(), checkfirst=False) | ||
|
||
op.add_column('product', sa.Column('required_level', sa.Integer(), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('product', 'required_level') | ||
|
||
op.execute(receipt_table.update() | ||
.where(receipt_table.c.status.in_(['REQUIRED_LEVEL'])) | ||
.values(status="INVALID") | ||
) | ||
tmp_status.create(op.get_bind(), checkfirst=False) | ||
op.execute("ALTER TABLE receipt ALTER COLUMN status TYPE _receiptstatus USING status::text::_receiptstatus") | ||
new_status.drop(op.get_bind(), checkfirst=False) | ||
old_status.create(op.get_bind(), checkfirst=False) | ||
op.execute("ALTER TABLE receipt ALTER COLUMN status TYPE receiptstatus USING status::text::receiptstatus") | ||
tmp_status.drop(op.get_bind(), checkfirst=False) | ||
# ### end Alembic commands ### |
30 changes: 30 additions & 0 deletions
30
common/alembic/versions/a2df38682595_add_is_free_column.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,30 @@ | ||
"""Add is_free column | ||
Revision ID: a2df38682595 | ||
Revises: 2822c456abc3 | ||
Create Date: 2024-01-18 13:55:23.731546 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'a2df38682595' | ||
down_revision = '2822c456abc3' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('product', sa.Column('is_free', sa.Boolean(), nullable=True, default=False)) | ||
op.execute("UPDATE product SET is_free=FALSE") | ||
op.alter_column("product", "is_free", nullable=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('product', 'is_free') | ||
# ### 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
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
Oops, something went wrong.