-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from zurdi15/romm-473
[ROMM-473] Enhanced region and language tagging
- Loading branch information
Showing
12 changed files
with
345 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""empty message | ||
Revision ID: 0012_add_regions_languages | ||
Revises: 0011_drop_has_cover | ||
Create Date: 2023-12-03 10:54:46.859106 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import mysql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '0012_add_regions_languages' | ||
down_revision = '0011_drop_has_cover' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('roms', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('regions', sa.JSON(), nullable=True)) | ||
batch_op.add_column(sa.Column('languages', sa.JSON(), nullable=True)) | ||
|
||
with op.batch_alter_table('roms', schema=None) as batch_op: | ||
# Set default values for languages and regions | ||
batch_op.execute("UPDATE roms SET languages = '[]'") | ||
batch_op.execute("UPDATE roms SET regions = JSON_ARRAY(region)") | ||
batch_op.drop_column('region') | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('roms', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('region', mysql.VARCHAR(length=20), nullable=True)) | ||
|
||
with op.batch_alter_table('roms', schema=None) as batch_op: | ||
batch_op.execute("UPDATE roms SET region = JSON_UNQUOTE(JSON_EXTRACT(regions, '$[0]'))") | ||
batch_op.drop_column('languages') | ||
batch_op.drop_column('regions') | ||
|
||
# ### 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.