Skip to content

Commit 1019274

Browse files
authored
Merge pull request #2860 from rommapp/romm-0062
[ROMM-2853] Update rom_file.category column enum
2 parents 47c6f4a + dbc9af3 commit 1019274

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Update rom_file.category column enum
2+
3+
Revision ID: 0062_rom_file_category_enum
4+
Revises: 0061_manual_metadata
5+
Create Date: 2026-01-03 10:03:00.00000
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
from sqlalchemy.dialects.postgresql import ENUM
12+
13+
from utils.database import is_postgresql
14+
15+
# revision identifiers, used by Alembic.
16+
revision = "0062_rom_file_category_enum"
17+
down_revision = "0061_manual_metadata"
18+
branch_labels = None
19+
depends_on = None
20+
21+
22+
def upgrade() -> None:
23+
connection = op.get_bind()
24+
25+
if is_postgresql(connection):
26+
rom_file_category_enum = ENUM(
27+
"GAME",
28+
"DLC",
29+
"HACK",
30+
"MANUAL",
31+
"PATCH",
32+
"UPDATE",
33+
"MOD",
34+
"DEMO",
35+
"TRANSLATION",
36+
"PROTOTYPE",
37+
name="romfilecategory",
38+
create_type=False,
39+
)
40+
rom_file_category_enum.create(connection, checkfirst=True)
41+
else:
42+
rom_file_category_enum = sa.Enum(
43+
"GAME",
44+
"DLC",
45+
"HACK",
46+
"MANUAL",
47+
"PATCH",
48+
"UPDATE",
49+
"MOD",
50+
"DEMO",
51+
"TRANSLATION",
52+
"PROTOTYPE",
53+
name="romfilecategory",
54+
)
55+
56+
with op.batch_alter_table("rom_files", schema=None) as batch_op:
57+
batch_op.alter_column("category", type_=rom_file_category_enum, nullable=True)
58+
59+
60+
def downgrade() -> None:
61+
pass

0 commit comments

Comments
 (0)