fix: use constrained foreign key for files track_type
This commit is contained in:
parent
bcaea16c19
commit
db976881f0
26 changed files with 1233 additions and 113 deletions
|
@ -22,6 +22,34 @@ The allowed CORS origins configuration moved from the database to the configurat
|
|||
|
||||
## :arrow_up: Upgrading
|
||||
|
||||
### Repair broken track types
|
||||
|
||||
:::caution
|
||||
|
||||
Please run this **before the upgrade procedure**!
|
||||
|
||||
:::
|
||||
|
||||
The database files track type field was previously not constrained and this might have lead to files referencing a now renamed or missing track type. To preserve as much data as possible during the database migration process, you need to check whether some files have broken or missing track type references and fix them accordingly. To list broken track type references, you can run the following command:
|
||||
|
||||
```bash
|
||||
sudo -u www-data libretime-api dbshell --command="
|
||||
SELECT f.id, f.track_type, f.track_title, f.artist_name, f.filepath
|
||||
FROM cc_files f
|
||||
WHERE NOT EXISTS (
|
||||
SELECT FROM cc_track_types tt
|
||||
WHERE tt.code = f.track_type
|
||||
);"
|
||||
```
|
||||
|
||||
If the above command outputs the following, no file needs fixing.
|
||||
|
||||
```
|
||||
id | track_type | track_title | artist_name | filepath
|
||||
----+------------+-------------+-------------+----------
|
||||
(0 rows)
|
||||
```
|
||||
|
||||
### New configuration file
|
||||
|
||||
:::caution
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue