fix: use track_type_id in smartblock criteria

Missing migration step from db976881f0

Fixes #1957
This commit is contained in:
jo 2022-07-11 16:38:22 +02:00 committed by Jonas L
parent fdd3ff1e5a
commit de21e3175a
2 changed files with 36 additions and 0 deletions

View File

@ -19,6 +19,13 @@ UPDATE "cc_files" file SET "track_type_id" = (
)
WHERE "track_type" IS NOT NULL;
UPDATE "cc_blockcriteria" criteria
SET "criteria" = 'track_type_id', "value" = (
SELECT "id" FROM "cc_track_types"
WHERE "code" = criteria."value"
)
WHERE "criteria" = 'track_type';
UPDATE "cc_pref" file SET "valstr" = (
SELECT "id" FROM "cc_track_types"
WHERE "code" = file."valstr"
@ -38,6 +45,13 @@ UPDATE "cc_files" file SET "track_type" = (
)
WHERE "track_type_id" IS NOT NULL;
UPDATE "cc_blockcriteria" criteria
SET "criteria" = 'track_type', "value" = (
SELECT "code" FROM "cc_track_types"
WHERE "id" = criteria."value"::int
)
WHERE "criteria" = 'track_type_id';
UPDATE "cc_pref" pref SET "valstr" = (
SELECT "code" FROM "cc_track_types"
WHERE "id" = pref."valstr"::int

View File

@ -52,6 +52,28 @@ If the above command outputs the following, no file needs fixing.
(0 rows)
```
In addition, the database smart block criteria value was previously referencing track types using codes, and should now reference track types using ids. You need to check whether some smart block have broken track type references and fix them accordingly. To list broken track type references, you can run the following command:
```bash
sudo -u libretime libretime-api dbshell --command="
SELECT b.name, c.criteria, c.modifier, c.value
FROM cc_blockcriteria c, cc_block b
WHERE c.block_id = b.id
AND NOT EXISTS (
SELECT FROM cc_track_types tt
WHERE tt.code = c.value
)
AND criteria = 'track_type';"
```
If the above command outputs the following, no smart block needs fixing.
```
name | criteria | modifier | value
------+----------+----------+-------
(0 rows)
```
### New configuration file
:::caution