mirror of
https://github.com/PR0M3TH3AN/Marlin.git
synced 2025-09-07 14:48:44 +00:00
Merge pull request #75 from PR0M3TH3AN/codex/implement-file-rename-handling-in-watcher
Implement rename trigger fix
This commit is contained in:
20
libmarlin/src/db/migrations/0007_fix_rename_trigger.sql
Normal file
20
libmarlin/src/db/migrations/0007_fix_rename_trigger.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- src/db/migrations/0007_fix_rename_trigger.sql
|
||||
PRAGMA foreign_keys = ON;
|
||||
PRAGMA journal_mode = WAL;
|
||||
|
||||
-- Recreate files_fts_au_file trigger using INSERT OR REPLACE
|
||||
DROP TRIGGER IF EXISTS files_fts_au_file;
|
||||
CREATE TRIGGER files_fts_au_file
|
||||
AFTER UPDATE OF path ON files
|
||||
BEGIN
|
||||
INSERT OR REPLACE INTO files_fts(rowid, path, tags_text, attrs_text)
|
||||
SELECT NEW.id,
|
||||
NEW.path,
|
||||
(SELECT IFNULL(GROUP_CONCAT(t.name, ' '), '')
|
||||
FROM file_tags ft
|
||||
JOIN tags t ON ft.tag_id = t.id
|
||||
WHERE ft.file_id = NEW.id),
|
||||
(SELECT IFNULL(GROUP_CONCAT(a.key || '=' || a.value, ' '), '')
|
||||
FROM attributes a
|
||||
WHERE a.file_id = NEW.id);
|
||||
END;
|
@@ -50,6 +50,10 @@ const MIGRATIONS: &[(&str, &str)] = &[
|
||||
"0006_drop_tags_canonical_id.sql",
|
||||
include_str!("migrations/0006_drop_tags_canonical_id.sql"),
|
||||
),
|
||||
(
|
||||
"0007_fix_rename_trigger.sql",
|
||||
include_str!("migrations/0007_fix_rename_trigger.sql"),
|
||||
),
|
||||
];
|
||||
|
||||
/* ─── schema helpers ─────────────────────────────────────────────── */
|
||||
|
Reference in New Issue
Block a user