-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
backend/alembic/versions/4f9ec96fc98e_add_unverified_tier.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,62 @@ | ||
"""Add unverified tier | ||
Revision ID: 4f9ec96fc98e | ||
Revises: 651ed2d244c5 | ||
Create Date: 2024-10-31 14:30:56.099043 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlalchemy.orm as orm | ||
from alembic_postgresql_enum import TableReference | ||
from src.limits.models import Tier | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "4f9ec96fc98e" | ||
down_revision: Union[str, None] = "651ed2d244c5" | ||
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.sync_enum_values( | ||
"public", | ||
"tiernames", | ||
["FREE", "ADMIN", "PREMIUM", "UNVERIFIED"], | ||
[ | ||
TableReference( | ||
table_schema="public", table_name="tier", column_name="tier_name" | ||
) | ||
], | ||
enum_values_to_rename=[], | ||
) | ||
session = orm.Session(bind=op.get_bind()) | ||
session.add(Tier(tier_name="UNVERIFIED", label="Unverified", gp_question_limit=0)) | ||
session.commit() | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
session = orm.Session(bind=op.get_bind()) | ||
unverified = session.scalar(sa.select(Tier).where(Tier.label == "Unverified")) | ||
session.delete(unverified) | ||
session.commit() | ||
|
||
op.sync_enum_values( | ||
"public", | ||
"tiernames", | ||
["FREE", "ADMIN", "PREMIUM"], | ||
[ | ||
TableReference( | ||
table_schema="public", table_name="tier", column_name="tier_name" | ||
) | ||
], | ||
enum_values_to_rename=[], | ||
) | ||
|
||
# ### 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