Music library not shown

Hi,
I don’t understand the problem I have with my music database. I have a shared MySQL database on a PI. Videos work well with all the PI’s on my local network, but no music file is shown on music selection screen. I have always the screen telling me “Your library is currently empty…”. But using phpMyAdmin I can see that MySQL database MyMusic82 has tables with a lot of lines. And when I click on “Enter files section”, I can see my library.
So what did I do wrong ?
I have last OSMC and Libreelec version.
Thanks.

If you provide logs this may allow us to spot the issue. When you go to the “files” section this is browsing a source which is completely different from the library and not derived from the database.

To get a better understanding of the problem you are experiencing we need more information from you. The best way to get this information is for you to upload logs that demonstrate your problem. You can learn more about how to submit a useful support request here.

Depending on the used skin you have to set the settings-level to standard or higher, in summary:

  • enable debug logging at settings->system->logging

  • reboot the OSMC device twice(!)

  • reproduce the issue

  • upload the log set (all configs and logs!) either using the Log Uploader method within the My OSMC menu in the GUI or the ssh method invoking command grab-logs -A

  • publish the provided URL from the log set upload, here

Thanks for your understanding. We hope that we can help you get up and running again shortly.

OSMC skin screenshot:

Hi,

I could finally reproduce this issue by using a small library because complete music library will produce a huge logging.

URL is https://paste.osmc.tv/miximowiqi

I’ve seen that several of these messages are shown :
2023-01-16 17:10:52.327 T:907 ERROR : SQL: [MyMusic82] The table does not exist
Query: select count(idSong) as NumSongs from songview

Indeed phpMyadmin tells me that table songview doesnt exist.

Thanks for help.

Your config seems correct to me. Perhaps there was an error when the database was first created. Have you tried just dropping the MyMusic82 database and see what happens when you restart Kodi and rebuilds a new one?

It doesn’t work better. I’ve tried again with a small music library. Here is the database export :

CREATE TABLE album (
idAlbum int(11) NOT NULL,
strAlbum varchar(256) DEFAULT NULL,
strMusicBrainzAlbumID text DEFAULT NULL,
strReleaseGroupMBID text DEFAULT NULL,
strArtistDisp text DEFAULT NULL,
strArtistSort text DEFAULT NULL,
strGenres text DEFAULT NULL,
strReleaseDate text DEFAULT NULL,
strOrigReleaseDate text DEFAULT NULL,
bBoxedSet int(11) NOT NULL DEFAULT 0,
bCompilation int(11) NOT NULL DEFAULT 0,
strMoods text DEFAULT NULL,
strStyles text DEFAULT NULL,
strThemes text DEFAULT NULL,
strReview text DEFAULT NULL,
strImage text DEFAULT NULL,
strLabel text DEFAULT NULL,
strType text DEFAULT NULL,
strReleaseStatus text DEFAULT NULL,
fRating float NOT NULL DEFAULT 0,
iVotes int(11) NOT NULL DEFAULT 0,
iUserrating int(11) NOT NULL DEFAULT 0,
lastScraped varchar(20) DEFAULT NULL,
bScrapedMBID int(11) NOT NULL DEFAULT 0,
strReleaseType text DEFAULT NULL,
iDiscTotal int(11) NOT NULL DEFAULT 0,
iAlbumDuration int(11) NOT NULL DEFAULT 0,
idInfoSetting int(11) NOT NULL DEFAULT 0,
dateAdded text DEFAULT NULL,
dateNew text DEFAULT NULL,
dateModified text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO album (idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseGroupMBID, strArtistDisp, strArtistSort, strGenres, strReleaseDate, strOrigReleaseDate, bBoxedSet, bCompilation, strMoods, strStyles, strThemes, strReview, strImage, strLabel, strType, strReleaseStatus, fRating, iVotes, iUserrating, lastScraped, bScrapedMBID, strReleaseType, iDiscTotal, iAlbumDuration, idInfoSetting, dateAdded, dateNew, dateModified) VALUES
(1, ‘Descanso Dominical’, NULL, NULL, ‘Mecano’, NULL, ‘Latin Pop’, ‘1988’, ‘1988’, 0, 0, NULL, NULL, NULL, NULL, NULL, ‘’, ‘’, ‘’, 0, 0, 0, NULL, 0, ‘album’, 1, 2934, 0, ‘2019-10-24 15:57:53’, ‘2023-01-17 16:37:51’, ‘2023-01-17 16:37:53’),
(2, ‘Aidalai’, NULL, NULL, ‘Mecano’, NULL, ‘Latin Pop’, ‘1991’, ‘1991’, 0, 0, NULL, NULL, NULL, NULL, NULL, ‘’, ‘’, ‘’, 0, 0, 0, NULL, 0, ‘album’, 1, 3518, 0, ‘2019-10-24 15:59:14’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’);
DELIMITER $$
CREATE TRIGGER tgrDeleteAlbum AFTER DELETE ON album FOR EACH ROW BEGIN DELETE FROM song WHERE song.idAlbum = old.idAlbum; DELETE FROM album_artist WHERE album_artist.idAlbum = old.idAlbum; DELETE FROM album_source WHERE album_source.idAlbum = old.idAlbum; DELETE FROM art WHERE media_id=old.idAlbum AND media_type=‘album’; END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrInsertAlbum BEFORE INSERT ON album FOR EACH ROW BEGIN IF NEW.dateNew IS NULL THEN SET NEW.dateNew = now(); END IF; SET NEW.dateModified = now(); END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrUpdateAlbum BEFORE UPDATE ON album FOR EACH ROW SET NEW.dateModified = now()
$$
DELIMITER ;

CREATE TABLE album_artist (
idArtist int(11) DEFAULT NULL,
idAlbum int(11) DEFAULT NULL,
iOrder int(11) DEFAULT NULL,
strArtist text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO album_artist (idArtist, idAlbum, iOrder, strArtist) VALUES
(2, 1, 0, ‘Mecano’),
(2, 2, 0, ‘Mecano’);
DELIMITER $$
CREATE TRIGGER tgrDeleteAlbumArtist AFTER DELETE ON album_artist FOR EACH ROW BEGIN INSERT INTO removed_link (idArtist, idMedia, idRole) VALUES(OLD.idArtist, OLD.idAlbum, -1); END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrInsertAlbumArtist AFTER INSERT ON album_artist FOR EACH ROW BEGIN DELETE FROM removed_link WHERE idArtist = NEW.idArtist AND idMedia = NEW.idAlbum AND idRole = -1; END
$$
DELIMITER ;

CREATE TABLE album_source (
idSource int(11) DEFAULT NULL,
idAlbum int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO album_source (idSource, idAlbum) VALUES
(1, 1),
(1, 2);

CREATE TABLE art (
art_id int(11) NOT NULL,
media_id int(11) DEFAULT NULL,
media_type text DEFAULT NULL,
type text DEFAULT NULL,
url text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO art (art_id, media_id, media_type, type, url) VALUES
(1, 1, ‘album’, ‘thumb’, ‘smb://192.168.1.30/Public/Ma Musique/Mecano/1990.Descanso Dominical/Folder.jpg’),
(2, 2, ‘album’, ‘thumb’, ‘smb://192.168.1.30/Public/Ma Musique/Mecano/1991.Aidalai/Folder.jpg’);

CREATE TABLE artist (
idArtist int(11) NOT NULL,
strArtist varchar(256) DEFAULT NULL,
strMusicBrainzArtistID text DEFAULT NULL,
strSortName text DEFAULT NULL,
strType text DEFAULT NULL,
strGender text DEFAULT NULL,
strDisambiguation text DEFAULT NULL,
strBorn text DEFAULT NULL,
strFormed text DEFAULT NULL,
strGenres text DEFAULT NULL,
strMoods text DEFAULT NULL,
strStyles text DEFAULT NULL,
strInstruments text DEFAULT NULL,
strBiography text DEFAULT NULL,
strDied text DEFAULT NULL,
strDisbanded text DEFAULT NULL,
strYearsActive text DEFAULT NULL,
strImage text DEFAULT NULL,
lastScraped varchar(20) DEFAULT NULL,
bScrapedMBID int(11) NOT NULL DEFAULT 0,
idInfoSetting int(11) NOT NULL DEFAULT 0,
dateAdded text DEFAULT NULL,
dateNew text DEFAULT NULL,
dateModified text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO artist (idArtist, strArtist, strMusicBrainzArtistID, strSortName, strType, strGender, strDisambiguation, strBorn, strFormed, strGenres, strMoods, strStyles, strInstruments, strBiography, strDied, strDisbanded, strYearsActive, strImage, lastScraped, bScrapedMBID, idInfoSetting, dateAdded, dateNew, dateModified) VALUES
(1, ‘[Missing Tag]’, ‘Artist Tag Missing’, ‘[Missing Tag]’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL),
(2, ‘Mecano’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, ‘2019-10-24 15:59:14’, ‘2023-01-17 16:37:51’, ‘2023-01-17 16:37:54’),
(3, ‘Cano, Ignacio’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, ‘2023-01-17 16:37:51’, ‘2023-01-17 16:37:51’),
(4, ‘Ignacio Cano’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(5, ‘José María Cano’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(6, ‘I. Cano’, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’);
DELIMITER $$
CREATE TRIGGER tgrDeleteArtist AFTER DELETE ON artist FOR EACH ROW BEGIN DELETE FROM album_artist WHERE album_artist.idArtist = old.idArtist; DELETE FROM song_artist WHERE song_artist.idArtist = old.idArtist; DELETE FROM discography WHERE discography.idArtist = old.idArtist; DELETE FROM art WHERE media_id=old.idArtist AND media_type=‘artist’; END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrInsertArtist BEFORE INSERT ON artist FOR EACH ROW BEGIN IF NEW.dateNew IS NULL THEN SET NEW.dateNew = now(); END IF; SET NEW.dateModified = now(); END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrUpdateArtist BEFORE UPDATE ON artist FOR EACH ROW SET NEW.dateModified = now()
$$
DELIMITER ;

CREATE TABLE audiobook (
idBook int(11) NOT NULL,
strBook varchar(256) DEFAULT NULL,
strAuthor text DEFAULT NULL,
bookmark int(11) DEFAULT NULL,
file text DEFAULT NULL,
dateAdded varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE discography (
idArtist int(11) DEFAULT NULL,
strAlbum text DEFAULT NULL,
strYear text DEFAULT NULL,
strReleaseGroupMBID text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE genre (
idGenre int(11) NOT NULL,
strGenre varchar(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO genre (idGenre, strGenre) VALUES
(1, ‘Latin Pop’);
DELIMITER $$
CREATE TRIGGER tgrInsertGenre AFTER INSERT ON genre FOR EACH ROW UPDATE versiontagscan SET genresupdated = now()
$$
DELIMITER ;

CREATE TABLE infosetting (
idSetting int(11) NOT NULL,
strScraperPath text DEFAULT NULL,
strSettings text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE path (
idPath int(11) NOT NULL,
strPath varchar(512) DEFAULT NULL,
strHash text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO path (idPath, strPath, strHash) VALUES
(1, ‘smb://192.168.1.30/Public/Ma Musique/Mecano/’, ‘d146712856c6e6a5a67cf88cd91345bc’),
(2, ‘smb://192.168.1.30/Public/Ma Musique/Mecano/1990.Descanso Dominical/’, ‘edcc8a3f43432d174900ae28670a71c5’),
(3, ‘smb://192.168.1.30/Public/Ma Musique/Mecano/1991.Aidalai/’, ‘80759d16e6df5b26be9c7f7c0f6bac68’);

CREATE TABLE removed_link (
idArtist int(11) DEFAULT NULL,
idMedia int(11) DEFAULT NULL,
idRole int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE role (
idRole int(11) NOT NULL,
strRole text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO role (idRole, strRole) VALUES
(1, ‘Artist’),
(2, ‘Composer’);

CREATE TABLE song (
idSong int(11) NOT NULL,
idAlbum int(11) DEFAULT NULL,
idPath int(11) DEFAULT NULL,
strArtistDisp text DEFAULT NULL,
strArtistSort text DEFAULT NULL,
strGenres text DEFAULT NULL,
strTitle varchar(512) DEFAULT NULL,
iTrack int(11) DEFAULT NULL,
iDuration int(11) DEFAULT NULL,
strReleaseDate text DEFAULT NULL,
strOrigReleaseDate text DEFAULT NULL,
strDiscSubtitle text DEFAULT NULL,
strFileName text DEFAULT NULL,
strMusicBrainzTrackID text DEFAULT NULL,
iTimesPlayed int(11) DEFAULT NULL,
iStartOffset int(11) DEFAULT NULL,
iEndOffset int(11) DEFAULT NULL,
lastplayed varchar(20) DEFAULT NULL,
rating float NOT NULL DEFAULT 0,
votes int(11) NOT NULL DEFAULT 0,
userrating int(11) NOT NULL DEFAULT 0,
comment text DEFAULT NULL,
mood text DEFAULT NULL,
iBPM int(11) NOT NULL DEFAULT 0,
iBitRate int(11) NOT NULL DEFAULT 0,
iSampleRate int(11) NOT NULL DEFAULT 0,
iChannels int(11) NOT NULL DEFAULT 0,
strReplayGain text DEFAULT NULL,
dateAdded text DEFAULT NULL,
dateNew text DEFAULT NULL,
dateModified text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO song (idSong, idAlbum, idPath, strArtistDisp, strArtistSort, strGenres, strTitle, iTrack, iDuration, strReleaseDate, strOrigReleaseDate, strDiscSubtitle, strFileName, strMusicBrainzTrackID, iTimesPlayed, iStartOffset, iEndOffset, lastplayed, rating, votes, userrating, comment, mood, iBPM, iBitRate, iSampleRate, iChannels, strReplayGain, dateAdded, dateNew, dateModified) VALUES
(1, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Hijo De La Luna’, 1, 260, ‘1988’, ‘1988’, ‘’, ‘01 Hijo De La Luna.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:45’, ‘2023-01-17 16:37:51’, ‘2023-01-17 16:37:51’),
(2, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘La Fuerza Del Destino’, 2, 311, ‘1988’, ‘1988’, ‘’, ‘02 La Fuerza Del Destino.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:46’, ‘2023-01-17 16:37:51’, ‘2023-01-17 16:37:52’),
(3, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Blues Del Esclavo’, 3, 277, ‘1988’, ‘1988’, ‘’, ‘03 El Blues Del Esclavo.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:47’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(4, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Los Amantes’, 4, 174, ‘1988’, ‘1988’, ‘’, ‘04 Los Amantes.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:48’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(5, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Mujer Contra Mujer’, 5, 246, ‘1988’, ‘1988’, ‘’, ‘05 Mujer Contra Mujer.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:48’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(6, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Por La Cara’, 6, 186, ‘1988’, ‘1988’, ‘’, ‘06 Por La Cara.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:49’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(7, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Une Femme Avec Une Femme (Mujer Contra Mujer)’, 7, 248, ‘1988’, ‘1988’, ‘’, ‘07 Une Femme Avec Une Femme (Mujer Contra Mujer).mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:50’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(8, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘No Hay Marcha En Nueva York’, 8, 258, ‘1988’, ‘1988’, ‘’, ‘08 No Hay Marcha En Nueva York.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:50’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(9, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Cine’, 9, 242, ‘1988’, ‘1988’, ‘’, ‘09 El Cine.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:51’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(10, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘"Eungenio" Salvador Dali’, 10, 324, ‘1988’, ‘1988’, ‘’, ‘10 'Eungenio' Salvador Dali.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:52’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(11, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Un Año Mas’, 11, 271, ‘1988’, ‘1988’, ‘’, ‘11 Un Año Mas.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:53’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(12, 1, 2, ‘Mecano’, NULL, ‘Latin Pop’, ‘Quedate En Madrid’, 12, 137, ‘1988’, ‘1988’, ‘’, ‘12 Quedate En Madrid.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:57:53’, ‘2023-01-17 16:37:52’, ‘2023-01-17 16:37:52’),
(13, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Fallo Positivo’, 1, 242, ‘1991’, ‘1991’, ‘’, ‘01 El Fallo Positivo.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:04’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(14, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Uno, El Dos, El Tres’, 2, 282, ‘1991’, ‘1991’, ‘’, ‘02 El Uno, El Dos, El Tres.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:05’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(15, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Bailando Salsa’, 3, 252, ‘1991’, ‘1991’, ‘’, ‘03 Bailando Salsa.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:06’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(16, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘El 7 De Septiembre’, 4, 302, ‘1991’, ‘1991’, ‘’, ‘04 El 7 De Septiembre.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:07’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(17, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Naturaleza Muerta’, 5, 305, ‘1991’, ‘1991’, ‘’, ‘05 Naturaleza Muerta.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:07’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(18, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘1917’, 6, 255, ‘1991’, ‘1991’, ‘’, ‘06 1917.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:08’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(19, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Una Rosa Es Una Rosa’, 7, 290, ‘1991’, ‘1991’, ‘’, ‘07 Una Rosa Es Una Rosa.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:09’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(20, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Lago Artificial’, 8, 235, ‘1991’, ‘1991’, ‘’, ‘08 El Lago Artificial.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:10’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(21, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Tú’, 9, 258, ‘1991’, ‘1991’, ‘’, ‘09 Tú.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:10’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(22, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Dalai Lama’, 10, 333, ‘1991’, ‘1991’, ‘’, ‘10 Dalai Lama.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:11’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(23, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘El Peón Del Rey De Negras’, 11, 291, ‘1991’, ‘1991’, ‘’, ‘11 El Peón Del Rey De Negras.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:12’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(24, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘J.C.’, 12, 263, ‘1991’, ‘1991’, ‘’, ‘12 J.C.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:13’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’),
(25, 2, 3, ‘Mecano’, NULL, ‘Latin Pop’, ‘Sentía’, 13, 210, ‘1991’, ‘1991’, ‘’, ‘13 Sentía.mp3’, NULL, 0, 0, 0, NULL, 0, 0, 0, ‘’, ‘’, 0, 320, 44100, 2, ‘’, ‘2019-10-24 15:59:14’, ‘2023-01-17 16:37:54’, ‘2023-01-17 16:37:54’);
DELIMITER $$
CREATE TRIGGER tgrDeleteSong AFTER DELETE ON song FOR EACH ROW BEGIN DELETE FROM song_artist WHERE song_artist.idSong = old.idSong; DELETE FROM song_genre WHERE song_genre.idSong = old.idSong; DELETE FROM art WHERE media_id=old.idSong AND media_type=‘song’; END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrInsertSong BEFORE INSERT ON song FOR EACH ROW BEGIN IF NEW.dateNew IS NULL THEN SET NEW.dateNew = now(); END IF; SET NEW.dateModified = now(); END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrUpdateSong BEFORE UPDATE ON song FOR EACH ROW SET NEW.dateModified = now()
$$
DELIMITER ;

CREATE TABLE song_artist (
idArtist int(11) DEFAULT NULL,
idSong int(11) DEFAULT NULL,
idRole int(11) DEFAULT NULL,
iOrder int(11) DEFAULT NULL,
strArtist text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO song_artist (idArtist, idSong, idRole, iOrder, strArtist) VALUES
(2, 1, 1, 0, ‘Mecano’),
(3, 1, 2, 0, ‘Cano, Ignacio’),
(2, 2, 1, 0, ‘Mecano’),
(3, 2, 2, 0, ‘Cano, Ignacio’),
(2, 3, 1, 0, ‘Mecano’),
(3, 3, 2, 0, ‘Cano, Ignacio’),
(2, 4, 1, 0, ‘Mecano’),
(3, 4, 2, 0, ‘Cano, Ignacio’),
(2, 5, 1, 0, ‘Mecano’),
(3, 5, 2, 0, ‘Cano, Ignacio’),
(2, 6, 1, 0, ‘Mecano’),
(3, 6, 2, 0, ‘Cano, Ignacio’),
(2, 7, 1, 0, ‘Mecano’),
(3, 7, 2, 0, ‘Cano, Ignacio’),
(2, 8, 1, 0, ‘Mecano’),
(3, 8, 2, 0, ‘Cano, Ignacio’),
(2, 9, 1, 0, ‘Mecano’),
(3, 9, 2, 0, ‘Cano, Ignacio’),
(2, 10, 1, 0, ‘Mecano’),
(3, 10, 2, 0, ‘Cano, Ignacio’),
(2, 11, 1, 0, ‘Mecano’),
(3, 11, 2, 0, ‘Cano, Ignacio’),
(2, 12, 1, 0, ‘Mecano’),
(3, 12, 2, 0, ‘Cano, Ignacio’),
(2, 13, 1, 0, ‘Mecano’),
(4, 13, 2, 0, ‘Ignacio Cano’),
(2, 14, 1, 0, ‘Mecano’),
(5, 14, 2, 0, ‘José María Cano’),
(2, 15, 1, 0, ‘Mecano’),
(5, 15, 2, 0, ‘José María Cano’),
(2, 16, 1, 0, ‘Mecano’),
(4, 16, 2, 0, ‘Ignacio Cano’),
(2, 17, 1, 0, ‘Mecano’),
(5, 17, 2, 0, ‘José María Cano’),
(2, 18, 1, 0, ‘Mecano’),
(4, 18, 2, 0, ‘Ignacio Cano’),
(2, 19, 1, 0, ‘Mecano’),
(6, 19, 2, 0, ‘I. Cano’),
(2, 20, 1, 0, ‘Mecano’),
(4, 20, 2, 0, ‘Ignacio Cano’),
(2, 21, 1, 0, ‘Mecano’),
(5, 21, 2, 0, ‘José María Cano’),
(2, 22, 1, 0, ‘Mecano’),
(4, 22, 2, 0, ‘Ignacio Cano’),
(2, 23, 1, 0, ‘Mecano’),
(5, 23, 2, 0, ‘José María Cano’),
(2, 24, 1, 0, ‘Mecano’),
(4, 24, 2, 0, ‘Ignacio Cano’),
(2, 25, 1, 0, ‘Mecano’),
(5, 25, 2, 0, ‘José María Cano’);
DELIMITER $$
CREATE TRIGGER tgrDeleteSongArtist AFTER DELETE ON song_artist FOR EACH ROW BEGIN INSERT INTO removed_link (idArtist, idMedia, idRole) VALUES(OLD.idArtist, OLD.idSong, OLD.idRole); END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER tgrInsertSongArtist AFTER INSERT ON song_artist FOR EACH ROW BEGIN DELETE FROM removed_link WHERE idArtist = NEW.idArtist AND idMedia = NEW.idSong AND idRole = NEW.idRole; END
$$
DELIMITER ;

CREATE TABLE song_genre (
idGenre int(11) DEFAULT NULL,
idSong int(11) DEFAULT NULL,
iOrder int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO song_genre (idGenre, idSong, iOrder) VALUES
(1, 1, 0),
(1, 2, 0),
(1, 3, 0),
(1, 4, 0),
(1, 5, 0),
(1, 6, 0),
(1, 7, 0),
(1, 8, 0),
(1, 9, 0),
(1, 10, 0),
(1, 11, 0),
(1, 12, 0),
(1, 13, 0),
(1, 14, 0),
(1, 15, 0),
(1, 16, 0),
(1, 17, 0),
(1, 18, 0),
(1, 19, 0),
(1, 20, 0),
(1, 21, 0),
(1, 22, 0),
(1, 23, 0),
(1, 24, 0),
(1, 25, 0);

CREATE TABLE source (
idSource int(11) NOT NULL,
strName text DEFAULT NULL,
strMultipath text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO source (idSource, strName, strMultipath) VALUES
(1, ‘Mecano’, ‘smb://192.168.1.30/Public/Ma Musique/Mecano’);
DELIMITER $$
CREATE TRIGGER tgrDeleteSource AFTER DELETE ON source FOR EACH ROW BEGIN DELETE FROM source_path WHERE source_path.idSource = old.idSource; DELETE FROM album_source WHERE album_source.idSource = old.idSource; END
$$
DELIMITER ;

CREATE TABLE source_path (
idSource int(11) DEFAULT NULL,
idPath int(11) DEFAULT NULL,
strPath varchar(512) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO source_path (idSource, idPath, strPath) VALUES
(1, 1, ‘smb://192.168.1.30/Public/Ma Musique/Mecano’);

CREATE TABLE version (
idVersion int(11) DEFAULT NULL,
iCompressCount int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO version (idVersion, iCompressCount) VALUES
(82, 0);

CREATE TABLE versiontagscan (
idVersion int(11) DEFAULT NULL,
iNeedsScan int(11) DEFAULT NULL,
lastscanned varchar(20) DEFAULT NULL,
lastcleaned varchar(20) DEFAULT NULL,
artistlinksupdated varchar(20) DEFAULT NULL,
genresupdated varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO versiontagscan (idVersion, iNeedsScan, lastscanned, lastcleaned, artistlinksupdated, genresupdated) VALUES
(82, 0, ‘2023-01-17 15:37:54’, NULL, NULL, ‘2023-01-17 16:37:51’);

ALTER TABLE album
ADD PRIMARY KEY (idAlbum),
ADD UNIQUE KEY idxAlbum_2 (strMusicBrainzAlbumID(36)),
ADD KEY idxAlbum (strAlbum(255)),
ADD KEY idxAlbum_1 (bCompilation),
ADD KEY idxAlbum_3 (idInfoSetting);

ALTER TABLE album_artist
ADD UNIQUE KEY idxAlbumArtist_1 (idAlbum,idArtist),
ADD UNIQUE KEY idxAlbumArtist_2 (idArtist,idAlbum);

ALTER TABLE album_source
ADD UNIQUE KEY idxAlbumSource_1 (idSource,idAlbum),
ADD UNIQUE KEY idxAlbumSource_2 (idAlbum,idSource);

ALTER TABLE art
ADD PRIMARY KEY (art_id),
ADD KEY ix_art (media_id,media_type(20),type(20));

ALTER TABLE artist
ADD PRIMARY KEY (idArtist),
ADD UNIQUE KEY idxArtist1 (strMusicBrainzArtistID(36)),
ADD KEY idxArtist (strArtist(255)),
ADD KEY idxArtist_2 (idInfoSetting);

ALTER TABLE audiobook
ADD PRIMARY KEY (idBook);

ALTER TABLE discography
ADD KEY idxDiscography_1 (idArtist);

ALTER TABLE genre
ADD PRIMARY KEY (idGenre),
ADD KEY idxGenre (strGenre(255));

ALTER TABLE infosetting
ADD PRIMARY KEY (idSetting);

ALTER TABLE path
ADD PRIMARY KEY (idPath),
ADD KEY idxPath (strPath(255));

ALTER TABLE role
ADD PRIMARY KEY (idRole),
ADD KEY idxRole (strRole(255));

ALTER TABLE song
ADD PRIMARY KEY (idSong),
ADD UNIQUE KEY idxSong7 (idAlbum,iTrack,strMusicBrainzTrackID(36)),
ADD KEY idxSong (strTitle(255)),
ADD KEY idxSong1 (iTimesPlayed),
ADD KEY idxSong2 (lastplayed),
ADD KEY idxSong3 (idAlbum),
ADD KEY idxSong6 (idPath,strFileName(255));

ALTER TABLE song_artist
ADD UNIQUE KEY idxSongArtist_1 (idSong,idArtist,idRole),
ADD KEY idxSongArtist_2 (idSong,idRole),
ADD KEY idxSongArtist_3 (idArtist,idRole),
ADD KEY idxSongArtist_4 (idRole);

ALTER TABLE song_genre
ADD UNIQUE KEY idxSongGenre_1 (idSong,idGenre),
ADD UNIQUE KEY idxSongGenre_2 (idGenre,idSong);

ALTER TABLE source
ADD PRIMARY KEY (idSource),
ADD KEY idxSource_1 (strName(255)),
ADD KEY idxSource_2 (strMultipath(255));

ALTER TABLE source_path
ADD UNIQUE KEY idxSourcePath_1 (idSource,idPath);

ALTER TABLE album
MODIFY idAlbum int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
ALTER TABLE art
MODIFY art_id int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
ALTER TABLE artist
MODIFY idArtist int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
ALTER TABLE audiobook
MODIFY idBook int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE genre
MODIFY idGenre int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
ALTER TABLE infosetting
MODIFY idSetting int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE path
MODIFY idPath int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
ALTER TABLE role
MODIFY idRole int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
ALTER TABLE song
MODIFY idSong int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
ALTER TABLE source
MODIFY idSource int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;