Update schema

This commit is contained in:
Vincent Riquer 2025-03-16 01:49:44 +01:00
parent 6cde6b4ada
commit 0214e59715
4 changed files with 40 additions and 2 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
currentdbversion=5
currentdbversion=6
checkDatabaseVersion() {
local dbversion
if dbversion=$(Select atom version <<<"\"1\" = 1")

View File

@ -1,5 +1,6 @@
#!/bin/bash
openDatabase() {
[[ -f "$database" ]] || populate_db=1
rm -f "$tempdir"/sqlite.{in,out}
mkfifo "$tempdir"/sqlite.{in,out}
sqlite3 -bail "$database" \
@ -13,7 +14,7 @@ openDatabase() {
exec 5>&3
exec 3> >(tee -a "$tempdir/debug.log" >&5)
fi
cat $schema >&3
(( populate_db )) && cat $schema >&3
echo '.separator ::AtOM:SQL:Sep::' >&3
echo 'PRAGMA foreign_keys = ON;' >&3
echo 'PRAGMA recursive_triggers = ON;' >&3

View File

@ -0,0 +1,35 @@
#!/bin/bash
upgradedatabase_5_6() {
echo "Upgrading database to version 6... (backup is $database.bak_v5)"
cp "$database" "$database.bak_v5"
echo 'DROP TRIGGER force_destination_update_on_tag_update;' >&3
echo '
CREATE TRIGGER IF NOT EXISTS force_destination_update_on_tag_update
AFTER UPDATE OF
genre,
albumartist,
year,
album,
disc,
artist,
track,
title,
composer,
performer,
releasecountry,
replaygain_alb,
replaygain_trk,
rate,
channels,
bitrate,
bitdepth
ON tags
BEGIN
UPDATE destination_files SET last_change=0
WHERE source_file_id=old.source_file;
END;
' >&3
Update atom version 6 <<<"1 = 1"
}

View File

@ -59,6 +59,8 @@ CREATE TABLE IF NOT EXISTS tags (
composer TEXT,
performer TEXT,
releasecountry TEXT,
replaygain_alb FLOAT,
replaygain_trk FLOAT,
depth INTEGER,
rate INTEGER,
channels INTEGER,