forked from mopidy/mopidy-local
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support musicbrainz fields in search and distinct. (Fixes mopidy#42)
- Loading branch information
1 parent
9b38637
commit 5246222
Showing
5 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
-- Mopidy-Local-SQLite schema upgrade v6 -> v7 | ||
|
||
BEGIN EXCLUSIVE TRANSACTION; | ||
|
||
CREATE INDEX track_disc_no_index ON track (disc_no); | ||
CREATE INDEX album_musicbrainz_id_index ON album (musicbrainz_id); | ||
CREATE INDEX artist_musicbrainz_id_index ON artist (musicbrainz_id); | ||
CREATE INDEX track_musicbrainz_id_index ON track (musicbrainz_id); | ||
|
||
DROP VIEW search; | ||
|
||
CREATE VIEW search AS | ||
SELECT docid AS docid, | ||
uri AS uri, | ||
name AS track_name, | ||
album_name AS album, | ||
artist_name AS artist, | ||
composer_name AS composer, | ||
performer_name AS performer, | ||
albumartist_name AS albumartist, | ||
genre AS genre, | ||
track_no AS track_no, | ||
coalesce(date, album_date) AS date, | ||
comment AS comment, | ||
disc_no AS disc_no, | ||
musicbrainz_id AS musicbrainz_trackid, | ||
album_musicbrainz_id AS musicbrainz_albumid, | ||
artist_musicbrainz_id AS musicbrainz_artistid | ||
|
||
FROM tracks; | ||
|
||
DROP TABLE fts; | ||
|
||
CREATE VIRTUAL TABLE fts USING fts3 ( | ||
uri, | ||
track_name, | ||
album, | ||
artist, | ||
composer, | ||
performer, | ||
albumartist, | ||
genre, | ||
track_no, | ||
date, | ||
comment, | ||
disc_no, | ||
musicbrainz_trackid, | ||
musicbrainz_albumid, | ||
musicbrainz_artistid | ||
); | ||
|
||
DROP TRIGGER track_after_insert; | ||
DROP TRIGGER track_after_update; | ||
|
||
CREATE TRIGGER track_after_insert AFTER INSERT ON track | ||
BEGIN | ||
INSERT INTO fts ( | ||
docid, | ||
uri, | ||
track_name, | ||
album, | ||
artist, | ||
composer, | ||
performer, | ||
albumartist, | ||
genre, | ||
track_no, | ||
date, | ||
comment, | ||
disc_no, | ||
musicbrainz_trackid, | ||
musicbrainz_albumid, | ||
musicbrainz_artistid | ||
) SELECT * FROM search WHERE docid = new.rowid; | ||
END; | ||
|
||
CREATE TRIGGER track_after_update AFTER UPDATE ON track | ||
BEGIN | ||
INSERT INTO fts ( | ||
docid, | ||
uri, | ||
track_name, | ||
album, | ||
artist, | ||
composer, | ||
performer, | ||
albumartist, | ||
genre, | ||
track_no, | ||
date, | ||
comment, | ||
disc_no, | ||
musicbrainz_trackid, | ||
musicbrainz_albumid, | ||
musicbrainz_artistid | ||
) SELECT * FROM search WHERE docid = new.rowid; | ||
END; | ||
|
||
-- update date | ||
|
||
INSERT INTO fts ( | ||
docid, | ||
uri, | ||
track_name, | ||
album, | ||
artist, | ||
composer, | ||
performer, | ||
albumartist, | ||
genre, | ||
track_no, | ||
date, | ||
comment, | ||
disc_no, | ||
musicbrainz_trackid, | ||
musicbrainz_albumid, | ||
musicbrainz_artistid | ||
) SELECT * FROM search; | ||
|
||
PRAGMA user_version = 7; -- update schema version | ||
|
||
END TRANSACTION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters