[db] Comeback for the files-table insert trigger
This commit is contained in:
parent
bae5a891c2
commit
a19ea35917
|
@ -400,9 +400,15 @@ static const struct db_init_query db_init_index_queries[] =
|
|||
|
||||
/* Triggers must be prefixed with trg_ for db_drop_triggers() to id them */
|
||||
|
||||
#define TRG_GROUPS_INSERT \
|
||||
"CREATE TRIGGER trg_groups_insert AFTER INSERT ON files FOR EACH ROW" \
|
||||
" BEGIN" \
|
||||
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \
|
||||
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (2, NEW.album_artist, NEW.songartistid);" \
|
||||
" END;"
|
||||
|
||||
#define TRG_GROUPS_UPDATE \
|
||||
"CREATE TRIGGER trg_groups_update AFTER UPDATE OF songartistid, songalbumid ON files FOR EACH ROW" \
|
||||
" WHEN (NEW.songartistid != 0 AND NEW.songalbumid != 0)" \
|
||||
" BEGIN" \
|
||||
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \
|
||||
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (2, NEW.album_artist, NEW.songartistid);" \
|
||||
|
@ -410,6 +416,7 @@ static const struct db_init_query db_init_index_queries[] =
|
|||
|
||||
static const struct db_init_query db_init_trigger_queries[] =
|
||||
{
|
||||
{ TRG_GROUPS_INSERT, "create trigger trg_groups_insert" },
|
||||
{ TRG_GROUPS_UPDATE, "create trigger trg_groups_update" },
|
||||
};
|
||||
|
||||
|
|
|
@ -986,7 +986,7 @@ static const struct db_upgrade_query db_upgrade_v2001_queries[] =
|
|||
#define U_V2002_SCVER_MINOR \
|
||||
"UPDATE admin SET value = '02' WHERE key = 'schema_version_minor';"
|
||||
|
||||
// This upgrade removes some triggers (will be done automatically by db_drop...)
|
||||
// This upgrade just changes triggers (will be done automatically by db_drop...)
|
||||
static const struct db_upgrade_query db_upgrade_v2002_queries[] =
|
||||
{
|
||||
{ U_V2002_SCVER_MINOR, "set schema_version_minor to 02" },
|
||||
|
|
Loading…
Reference in New Issue