mirror of
https://github.com/rommapp/romm.git
synced 2026-07-01 08:16:21 +00:00
fix: Migration 0034 compatibility with MySQL
`DISTINCT` cannot be used within `JSON_ARRAYAGG` in MySQL, so it was removed. Also, the PostgreSQL query was simplified and now generates JSONB columns, to be consistent with all the other tables.
This commit is contained in:
@@ -115,9 +115,9 @@ def upgrade() -> None:
|
||||
'Autogenerated ' || collection_type || ' collection' AS description,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
array_to_json(array_agg(rom_id)) as rom_ids,
|
||||
array_to_json(array_agg(path_cover_s)) as path_covers_s,
|
||||
array_to_json(array_agg(path_cover_l)) as path_covers_l
|
||||
jsonb_agg(rom_id) as rom_ids,
|
||||
jsonb_agg(path_cover_s) as path_covers_s,
|
||||
jsonb_agg(path_cover_l) as path_covers_l
|
||||
FROM (
|
||||
SELECT * FROM genres_collection
|
||||
UNION ALL
|
||||
@@ -149,7 +149,7 @@ def upgrade() -> None:
|
||||
connection.execute(
|
||||
sa.text(
|
||||
"""
|
||||
CREATE OR REPLACE VIEW virtual_collections AS
|
||||
CREATE OR REPLACE VIEW virtual_collections AS
|
||||
WITH genres AS (
|
||||
SELECT
|
||||
r.id as rom_id,
|
||||
@@ -236,9 +236,9 @@ def upgrade() -> None:
|
||||
CONCAT('Autogenerated ', collection_name, ' collection') AS description,
|
||||
NOW() AS created_at,
|
||||
NOW() AS updated_at,
|
||||
JSON_ARRAYAGG(DISTINCT rom_id) as rom_ids,
|
||||
JSON_ARRAYAGG(DISTINCT path_cover_s) as path_covers_s,
|
||||
JSON_ARRAYAGG(DISTINCT path_cover_l) as path_covers_l
|
||||
JSON_ARRAYAGG(rom_id) as rom_ids,
|
||||
JSON_ARRAYAGG(path_cover_s) as path_covers_s,
|
||||
JSON_ARRAYAGG(path_cover_l) as path_covers_l
|
||||
FROM
|
||||
(
|
||||
SELECT * FROM genres
|
||||
|
||||
Reference in New Issue
Block a user