Compare commits

...

1 Commits

Author SHA1 Message Date
Vincent Riquer
7df37f2756 Update schema 2025-03-16 03:02:50 +01:00
4 changed files with 42 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,37 @@
#!/bin/bash
upgradedatabase_5_6() {
echo "Upgrading database to version 6... (backup is $database.bak_v5)"
cp "$database" "$database.bak_v5"
echo '
ALTER TABLE tags ADD COLUMN replaygain_alb FLOAT;
ALTER TABLE tags ADD COLUMN replaygain_trk FLOAT;
DROP TRIGGER force_destination_update_on_tag_update;
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,