Skip to content

Commit 67efe62

Browse files
committed
Merge branch 'master' into only-ids-param
2 parents c9879b7 + 875dc56 commit 67efe62

File tree

37 files changed

+436
-184
lines changed

37 files changed

+436
-184
lines changed

.github/workflows/migrations.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Run Migrations
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "backend/alembic/versions/**"
7+
8+
permissions: read-all
9+
10+
jobs:
11+
migrate-postgres:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
checks: write
15+
pull-requests: write
16+
services:
17+
postgres:
18+
image: postgres:15
19+
env:
20+
POSTGRES_USER: user
21+
POSTGRES_PASSWORD: password
22+
POSTGRES_DB: testdb
23+
ports:
24+
- 5432:5432
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Install uv
35+
uses: astral-sh/[email protected]
36+
37+
- name: Install python
38+
run: uv python install 3.13
39+
40+
- name: Install dependencies
41+
run: uv sync
42+
43+
- name: Run PostgreSQL Migrations
44+
working-directory: backend
45+
env:
46+
ROMM_DB_DRIVER: postgresql
47+
DB_HOST: localhost
48+
DB_PORT: 5432
49+
DB_USER: user
50+
DB_PASSWD: password
51+
DB_NAME: testdb
52+
ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
53+
ROMM_BASE_PATH: romm_test
54+
run: uv run alembic upgrade head
55+
56+
migrate-mariadb:
57+
runs-on: ubuntu-latest
58+
permissions:
59+
checks: write
60+
pull-requests: write
61+
services:
62+
mariadb:
63+
image: mariadb:10.11
64+
env:
65+
MARIADB_USER: user
66+
MARIADB_PASSWORD: password
67+
MARIADB_DATABASE: testdb
68+
MARIADB_ROOT_PASSWORD: root
69+
ports:
70+
- 3306:3306
71+
options: >-
72+
--health-cmd "mysqladmin ping -h 127.0.0.1 -u root --password=root"
73+
--health-interval 10s
74+
--health-timeout 5s
75+
--health-retries 5
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/[email protected]
79+
80+
- name: Install mariadb connectors
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install -y libmariadb3 libmariadb-dev
84+
85+
- name: Install uv
86+
uses: astral-sh/[email protected]
87+
88+
- name: Install python
89+
run: uv python install 3.13
90+
91+
- name: Install dependencies
92+
run: uv sync
93+
94+
- name: Run MariaDB Migrations
95+
working-directory: backend
96+
env:
97+
ROMM_DB_DRIVER: mariadb
98+
DB_HOST: 127.0.0.1
99+
DB_PORT: 3306
100+
DB_USER: user
101+
DB_PASSWD: password
102+
DB_NAME: testdb
103+
ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
104+
ROMM_BASE_PATH: romm_test
105+
run: uv run alembic upgrade head

backend/alembic/versions/0063_roms_metadata_player_count.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ def upgrade():
9898
'[]'::jsonb
9999
) AS age_ratings,
100100
101-
COALESCE(
102-
NULLIF(r.manual_metadata ->> 'player_count', '1'),
103-
NULLIF(r.ss_metadata ->> 'player_count', '1'),
104-
NULLIF(r.igdb_metadata ->> 'player_count', '1'),
105-
NULLIF(r.gamelist_metadata ->> 'player_count', '1'),
106-
'1'
107-
) AS player_count,
108-
109101
CASE
110102
WHEN r.manual_metadata IS NOT NULL AND r.manual_metadata ? 'first_release_date' AND
111103
r.manual_metadata ->> 'first_release_date' NOT IN ('null', 'None', '0', '0.0') AND
@@ -155,7 +147,15 @@ def upgrade():
155147
CASE WHEN launchbox_rating IS NOT NULL THEN 1 ELSE 0 END +
156148
CASE WHEN gamelist_rating IS NOT NULL THEN 1 ELSE 0 END)
157149
ELSE NULL
158-
END AS average_rating
150+
END AS average_rating,
151+
152+
COALESCE(
153+
NULLIF(r.manual_metadata ->> 'player_count', '1'),
154+
NULLIF(r.ss_metadata ->> 'player_count', '1'),
155+
NULLIF(r.igdb_metadata ->> 'player_count', '1'),
156+
NULLIF(r.gamelist_metadata ->> 'player_count', '1'),
157+
'1'
158+
) AS player_count
159159
FROM (
160160
SELECT
161161
r.id,
@@ -283,14 +283,6 @@ def upgrade():
283283
JSON_ARRAY()
284284
) AS age_ratings,
285285
286-
COALESCE(
287-
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.manual_metadata, '$.player_count')), '1'),
288-
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.ss_metadata, '$.player_count')), '1'),
289-
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.igdb_metadata, '$.player_count')), '1'),
290-
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.gamelist_metadata, '$.player_count')), '1'),
291-
'1'
292-
) AS player_count,
293-
294286
CASE
295287
WHEN JSON_CONTAINS_PATH(r.manual_metadata, 'one', '$.first_release_date') AND
296288
JSON_UNQUOTE(JSON_EXTRACT(r.manual_metadata, '$.first_release_date')) NOT IN ('null', 'None', '0', '0.0') AND
@@ -344,7 +336,15 @@ def upgrade():
344336
CASE WHEN launchbox_rating IS NOT NULL THEN 1 ELSE 0 END +
345337
CASE WHEN gamelist_rating IS NOT NULL THEN 1 ELSE 0 END)
346338
ELSE NULL
347-
END AS average_rating
339+
END AS average_rating,
340+
341+
COALESCE(
342+
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.manual_metadata, '$.player_count')), '1'),
343+
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.ss_metadata, '$.player_count')), '1'),
344+
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.igdb_metadata, '$.player_count')), '1'),
345+
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(r.gamelist_metadata, '$.player_count')), '1'),
346+
'1'
347+
) AS player_count
348348
FROM (
349349
SELECT
350350
id,
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Update rom_file.category column enum to include cheats
2+
3+
Revision ID: 0067_romfile_category_enum_cheat
4+
Revises: 0066_fix_empty_flashpoint_id
5+
Create Date: 2026-01-25 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 = "0067_romfile_category_enum_cheat"
17+
down_revision = "0066_fix_empty_flashpoint_id"
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+
"CHEAT",
38+
name="romfilecategory",
39+
create_type=False,
40+
)
41+
rom_file_category_enum.create(connection, checkfirst=True)
42+
else:
43+
rom_file_category_enum = sa.Enum(
44+
"GAME",
45+
"DLC",
46+
"HACK",
47+
"MANUAL",
48+
"PATCH",
49+
"UPDATE",
50+
"MOD",
51+
"DEMO",
52+
"TRANSLATION",
53+
"PROTOTYPE",
54+
"CHEAT",
55+
name="romfilecategory",
56+
)
57+
58+
with op.batch_alter_table("rom_files", schema=None) as batch_op:
59+
batch_op.alter_column("category", type_=rom_file_category_enum, nullable=True)
60+
61+
62+
def downgrade() -> None:
63+
pass

backend/endpoints/rom.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,55 +351,55 @@ def get_roms(
351351
genres_logic: Annotated[
352352
str,
353353
Query(
354-
description="Logic operator for genres filter: 'any' (OR) or 'all' (AND).",
354+
description="Logic operator for genres filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
355355
),
356356
] = "any",
357357
franchises_logic: Annotated[
358358
str,
359359
Query(
360-
description="Logic operator for franchises filter: 'any' (OR) or 'all' (AND).",
360+
description="Logic operator for franchises filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
361361
),
362362
] = "any",
363363
collections_logic: Annotated[
364364
str,
365365
Query(
366-
description="Logic operator for collections filter: 'any' (OR) or 'all' (AND).",
366+
description="Logic operator for collections filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
367367
),
368368
] = "any",
369369
companies_logic: Annotated[
370370
str,
371371
Query(
372-
description="Logic operator for companies filter: 'any' (OR) or 'all' (AND).",
372+
description="Logic operator for companies filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
373373
),
374374
] = "any",
375375
age_ratings_logic: Annotated[
376376
str,
377377
Query(
378-
description="Logic operator for age ratings filter: 'any' (OR) or 'all' (AND).",
378+
description="Logic operator for age ratings filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
379379
),
380380
] = "any",
381381
regions_logic: Annotated[
382382
str,
383383
Query(
384-
description="Logic operator for regions filter: 'any' (OR) or 'all' (AND).",
384+
description="Logic operator for regions filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
385385
),
386386
] = "any",
387387
languages_logic: Annotated[
388388
str,
389389
Query(
390-
description="Logic operator for languages filter: 'any' (OR) or 'all' (AND).",
390+
description="Logic operator for languages filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
391391
),
392392
] = "any",
393393
statuses_logic: Annotated[
394394
str,
395395
Query(
396-
description="Logic operator for statuses filter: 'any' (OR) or 'all' (AND).",
396+
description="Logic operator for statuses filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
397397
),
398398
] = "any",
399399
player_counts_logic: Annotated[
400400
str,
401401
Query(
402-
description="Logic operator for player counts filter: 'any' (OR) or 'all' (AND).",
402+
description="Logic operator for player counts filter: 'any' (OR), 'all' (AND) or 'none' (NOT).",
403403
),
404404
] = "any",
405405
order_by: Annotated[

0 commit comments

Comments
 (0)