-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
62e8366
commit ff0674b
Showing
6 changed files
with
218 additions
and
8 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
migrations/versions/81cfa0d8b36c_add_conciergemiiactions.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,151 @@ | ||
"""Add ConciergeMiiActions | ||
Revision ID: 81cfa0d8b36c | ||
Revises: 357b58eaf27b | ||
Create Date: 2024-06-29 17:47:17.413325 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "81cfa0d8b36c" | ||
down_revision = "357b58eaf27b" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# We need some workarounds to cast the integer value to the enum. | ||
# First drop the null constraint. | ||
op.alter_column( | ||
"concierge_miis", "action", existing_type=sa.INTEGER(), nullable=True | ||
) | ||
|
||
# Set everything to null | ||
op.execute( | ||
""" | ||
UPDATE concierge_miis | ||
SET action = NULL; | ||
""" | ||
) | ||
|
||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("concierge_miis", schema=None) as batch_op: | ||
batch_op.alter_column( | ||
"action", | ||
existing_type=sa.INTEGER(), | ||
type_=sa.Enum( | ||
"NormalMaleA", | ||
"NormalFemaleS", | ||
"NormalMaleS", | ||
"NormalFemaleS2", | ||
"NormalMaleS2", | ||
"CheerfulMaleA", | ||
"CheerfulFemaleS", | ||
"CheerfulMaleS", | ||
"SaluteMaleA", | ||
"SaluteFemaleS", | ||
"SaluteMaleS", | ||
"ForeignerA", | ||
"ForeignerS", | ||
"CelebrityA", | ||
"CelebrityS", | ||
"CelebrationA", | ||
"CelebrationS", | ||
"AmazingA", | ||
"AmazingS", | ||
"GreetingS", | ||
"ApologyS", | ||
"Zundoko", | ||
"Takeshi", | ||
name="conciergemiiactions", | ||
), | ||
existing_nullable=False, | ||
postgresql_using="action::text::conciergemiiactions", | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
# Now set all columns to the default (NormalMaleA) | ||
op.execute( | ||
""" | ||
UPDATE concierge_miis | ||
SET action = 'NormalMaleA'; | ||
""" | ||
) | ||
|
||
# Finally re-add the constraint. | ||
op.alter_column( | ||
"concierge_miis", | ||
"action", | ||
existing_type=sa.Enum(name="conciergemiiactions"), | ||
nullable=False, | ||
) | ||
|
||
|
||
def downgrade(): | ||
# Just reverse the upgrade | ||
op.alter_column( | ||
"concierge_miis", | ||
"action", | ||
existing_type=sa.Enum(name="conciergemiiactions"), | ||
nullable=True, | ||
) | ||
|
||
# Set everything to null | ||
op.execute( | ||
""" | ||
UPDATE concierge_miis | ||
SET action = NULL; | ||
""" | ||
) | ||
|
||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table("concierge_miis", schema=None) as batch_op: | ||
batch_op.alter_column( | ||
"action", | ||
existing_type=sa.Enum( | ||
"NormalMaleA", | ||
"NormalFemaleS", | ||
"NormalMaleS", | ||
"NormalFemaleS2", | ||
"NormalMaleS2", | ||
"CheerfulMaleA", | ||
"CheerfulFemaleS", | ||
"CheerfulMaleS", | ||
"SaluteMaleA", | ||
"SaluteFemaleS", | ||
"SaluteMaleS", | ||
"ForeignerA", | ||
"ForeignerS", | ||
"CelebrityA", | ||
"CelebrityS", | ||
"CelebrationA", | ||
"CelebrationS", | ||
"AmazingA", | ||
"AmazingS", | ||
"GreetingS", | ||
"ApologyS", | ||
"Zundoko", | ||
"Takeshi", | ||
name="conciergemiiactions", | ||
), | ||
type_=sa.INTEGER(), | ||
existing_nullable=False, | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
op.execute( | ||
""" | ||
UPDATE concierge_miis | ||
SET action = 1; | ||
""" | ||
) | ||
|
||
op.alter_column( | ||
"concierge_miis", "action", existing_type=sa.INTEGER(), nullable=False | ||
) |
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