Commit Graph
82 Commits
Author SHA1 Message Date
Sam Dornan b5070cd984 fix(backend): keep derived rom state in step with its source (#4931) 2026-09-30 11:49:11 -04:00
Sam DornanandClaude Opus 5 c3b32a7710 fix(backend): make the 0122 downgrade work on MariaDB, and trim comments
Adding a composite index that leads with a foreign-key column lets InnoDB
re-point the constraint at it and discard the implicit single-column index.
Reversing 0122 then failed with "Cannot drop index 'ix_rom_user_user_rom':
needed in a foreign key constraint" on `rom_user.user_id`, and would have on
`screenshots.rom_id`. The downgrade now restores those two implicit indexes
first, and a full up/down/up cycle leaves the schema byte-identical to a
database that never ran the migration.

Also sets `path_separator = os` in alembic.ini, silencing the deprecation
warning about the legacy space/comma/colon path splitting. `prepend_sys_path`
holds a single entry, so the behaviour is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeQBXh6SJyxXVHSL5EuoF
2026-09-07 14:04:01 +00:00
Sam DornanandClaude Opus 5 a429c4b9db perf(backend): add the missing gallery indexes and reconcile model/schema drift
Four query shapes had no index that could serve both their predicate and
their sort, and a class of foreign-key columns was relying on an implicit
index that only MariaDB and MySQL provide.

New portable indexes:

- `screenshots (rom_id, user_id)`. `Save.screenshot` / `State.screenshot`
  resolve a thumbnail per row, so this lookup runs once per card on the
  continue-playing rail. 0093 added the equivalent to `states` and noted
  `saves` already had it; `screenshots` was missed.
- `rom_user (user_id, rom_id)` and `rom_user (user_id, last_played)`.
  `unique_rom_user_props` leads with `rom_id`, which covers the gallery's
  outer join but not the reverse direction, where sorting or scoping by a
  per-user column starts from this table.
- `roms (platform_id, name_sort_key)`. The gallery is browsed one platform
  at a time and ordered by name, and no index carried both columns. On a
  120k-row library across 20 platforms this takes the first page from
  5.8ms/1568 buffers to 0.6ms/75 buffers. Deep offsets converge, since the
  skipped rows are walked either way.

New PostgreSQL-only foreign-key indexes:

MariaDB and MySQL index every foreign key whose column is not already some
index's leftmost prefix; PostgreSQL does not. Eight such columns are queried
directly or walked by `ON DELETE`, so they get a real index there. Creating
them everywhere would leave the other backends with duplicates, so they are
dialect-gated and exempt from autogenerate.

Model/schema reconciliation:

Fifteen live indexes existed only in the migrations. Worse, `alembic/env.py`
never imported six models, so `devices`, `client_tokens`, `device_save_sync`,
`sync_sessions`, `play_sessions` and `streaming_container_adoptions` were
absent from the metadata autogenerate compares against, and autogenerate in
fact failed outright resolving `saves.origin_device_id`. With the imports
fixed it would have proposed dropping every one of those indexes.

Declares all of them on their models, matches `PlaySession` to the unique
index 0076 actually created, and adds a test that fails on any future index
drift so this cannot silently recur.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeQBXh6SJyxXVHSL5EuoF
2026-09-07 13:46:35 +00:00
Georges-Antoine Assi 389e768ee8 cleanup 2026-07-20 19:04:59 -04:00
SpinnichandClaude Opus 4.8 82caaf87a9 fix(platforms): address review feedback on PR #3855
Bound the user-authored fields. `description` (TEXT) and `custom_name`
(VARCHAR(400)) had no length constraint, so an oversized value reached the
database and surfaced as an unhandled DataError, turning a bad request into
a 500. Both are now validated against the column limits, which are defined
next to the columns so the bounds can't drift from the schema. The
`custom_name` case predates this branch but shares the line of code.

Make platform updates a true partial update. The shared API service took a
whole Platform object and sent every field, so the v1 rename drawer replayed
whatever description it happened to be holding; if another client had changed
the description in the meantime, renaming silently reverted it. The service
now takes explicit optional fields, so omitting one means "leave it alone"
rather than "write back my cached copy".

Watch the two form fields independently. Re-seeding both whenever either
canonical value changed meant a socket update touching only the name threw
away an unsaved description edit, and vice versa.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 20:01:05 +00:00
SpinnichandClaude Opus 4.8 98e8ae7599 feat(platforms): add editable platform descriptions
Custom platforms could only be distinguished by name, which is often not
enough context (e.g. a "Sega - Genesis/Mega Drive (Unofficial)" folder
holding aftermarket and unlicensed dumps). Platforms now carry an
optional free-text description, mirroring collections.

The column is nullable and defaults to "", matching custom_name, so a
rescan (which merges a freshly scanned Platform over the existing row)
leaves it untouched. update_platform patches only the fields sent, so an
omitted description is preserved and an empty string clears it.

Surfaced in the v2 UI only: the Settings tab name form now covers both
custom_name and description, and PlatformHead renders the description as
a chip alongside the metadata chips. v1 is frozen and gets no new UI, but
round-trips the field unchanged through the shared API service.

Closes #3402

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 19:00:30 +00:00
Georges-Antoine Assi 4928041593 manual cleanu 2026-04-12 11:04:12 -04:00
Georges-Antoine Assi cc309983ff fix scrolling and test 2025-10-31 11:50:51 -04:00
Georges-Antoine Assi 97ed8072dd add is_favorite migration 2025-10-18 13:27:19 -04:00
Georges-Antoine Assi 6eed0b6c7f Set platform metadata slugs on models in DB 2025-09-22 21:48:45 -04:00
Michael Manganiello e4e3928d1b misc: Apply import sorting 2025-09-04 11:17:00 -03:00
Georges-Antoine Assi f9c2c2f916 remove unused import 2025-08-23 15:25:05 -04:00
Georges-Antoine Assi e615f39905 grab file size from rom for paltform 2025-08-23 15:22:29 -04:00
Georges-Antoine Assi 0dadf8681e fix updating smart collections 2025-08-19 15:53:03 -04:00
Georges-Antoine Assi 13ac6104ce Raise lazy joins so all complex joins are explicit 2025-08-19 10:02:11 -04:00
Georges-Antoine Assi 4cf3641fa3 Use column properties to calculate fs_size_bytes 2025-08-14 23:14:41 -04:00
Georges-Antoine Assi 59a2e5d5aa move away from explicit LIST use 2025-07-24 16:41:17 -04:00
Georges-Antoine Assi 1bb33be803 more work migrating slugs 2025-07-24 09:30:57 -04:00
Georges-Antoine Assi aaf6741e93 Create safe filesystem handler 2025-07-17 12:30:57 -04:00
Georges-Antoine Assi c5f3379957 remove is_fully_iden 2025-07-12 20:40:08 -04:00
Georges-Antoine Assi 8613a9739d add ra and hasheous to is_identified 2025-07-12 20:35:32 -04:00
Georges-Antoine Assi 37fd3031bf updates to hasheous 2025-06-15 22:17:05 -04:00
Georges-Antoine Assi 318661bc45 Merge branch 'master' into romm-403 2025-06-13 11:51:45 -04:00
zurdi 8370b79a83 feat: add 'missing_from_fs' property to various schemas and update related logic for better tracking of missing files 2025-06-12 22:18:06 +00:00
zurdi b52ea89115 feat: add 'missing' flag to platforms and roms, update related handlers and schemas 2025-06-12 01:20:20 +00:00
Georges-Antoine Assi fd705e41ce add and store fake launchbox IDs 2025-05-23 14:13:19 -04:00
Georges-Antoine Assi 2d7c3be6ae update frontnend to support launchbox 2025-05-20 17:07:05 -04:00
zurdi 30a0be2c4c Merge branch 'master' into HEAD 2025-04-10 22:56:55 +00:00
Georges-Antoine Assi 672a5c6644 Merge branch 'master' into true-pagination 2025-04-05 20:41:03 -04:00
Georges-Antoine Assi 51cd16634c add dedicated emulatorjs save quick button 2025-03-26 10:56:48 -04:00
Georges-Antoine Assi 7f7b97a9cc Merge branch 'master' into true-pagination 2025-03-25 17:39:36 -04:00
Georges-Antoine Assi 581cdf742c fix pagination speeds 2025-03-21 00:07:27 -04:00
Georges-Antoine Assi 887ccf9f26 [ROMM-1761] Show platform disk size in sidebar 2025-03-20 18:12:10 -04:00
zurdi 9d96501b9e Merge remote-tracking branch 'origin/master' into feature/screenscraper-integration 2025-01-31 00:12:44 +00:00
Georges-Antoine Assi b659ebe97f [ROMM-1529] 2025-01-23 19:29:16 -05:00
zurdi 4aa2d49221 feat: fully integrated screenscrapper 2025-01-03 03:08:02 +00:00
zurdi 9645fab707 feat: Added custom name for platforms 2024-12-24 02:30:27 +00:00
Georges-Antoine Assi d0ccd6a0cd Merge branch 'master' into feat/retro_achievements 2024-12-14 21:24:49 -05:00
Georges-Antoine Assi d172f2f3ef hotfix some sqlalchemy models 2024-12-09 19:21:00 -05:00
zurdi 5eefdda9d8 refactor aspect_ratio field to use string type and update related components 2024-12-03 10:51:29 +00:00
zurdi b670b68df3 added default aspect ratio in platform table 2024-12-01 18:22:27 +00:00
zurdi be87d92cf7 fixed platform info migration and models 2024-11-28 12:28:29 +00:00
zurdi 80b7cc7333 added basic platform info from the igdb api call 2024-11-27 11:43:06 +00:00
SaraVieira 11b46494a7 start work on retro achievements 2024-08-31 19:09:20 +01:00
Michael Manganiello 004c0b634e fix: Make some DB columns non-nullable
This change makes some database columns non-nullable, and includes the
migration to seamlessly upgrade the schema.

It includes:
* User and Platform names
* Every boolean column
2024-07-07 11:07:27 -03:00
Michael Manganiello e1bcd9cc06 misc: Use Python future annotations
Simplify annotations by using `__future__.annotations`, so there's no
need to add typing using types as strings.
2024-06-30 12:19:37 -03:00
Michael Manganiello b99ededced misc: Migrate to SQLAlchemy declarative models
This change applies the guided migration process recommended by
SQLAlchemy [1], up to step 4, to have declarative ORM models that better
support Python typing.

The change was tested by running `alembic check`, which does not find
any schema changes.

Errors reported by `mypy` go down to 170, from the original 223 in the
current `master` commit.

[1] https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#migrating-an-existing-mapping
2024-06-25 23:03:20 -03:00
Georges-Antoine Assi b075e93321 Merge branch 'master' into trunk-io 2024-05-24 16:47:19 -04:00
Georges-Antoine Assi ac59fa16eb hotfix scanning rom_count field 2024-05-24 09:56:41 -04:00
Georges-Antoine Assi 7c5da34ddf fix slow fetching of platform 2024-05-23 23:18:19 -04:00