migration3-5.sql 2.94 KB
Newer Older
1
"CREATE TEMPORARY TABLE " + File::Table::Name + "_backup("
2 3 4 5 6 7 8 9 10 11 12 13
  "id_file INTEGER PRIMARY KEY AUTOINCREMENT,"
  "media_id INT NOT NULL,"
  "mrl TEXT,"
  "type UNSIGNED INTEGER,"
  "last_modification_date UNSIGNED INT,"
  "size UNSIGNED INT,"
  "parser_step INTEGER NOT NULL DEFAULT 0,"
  "parser_retries INTEGER NOT NULL DEFAULT 0,"
  "folder_id UNSIGNED INTEGER,"
  "is_present BOOLEAN NOT NULL DEFAULT 1,"
  "is_removable BOOLEAN NOT NULL,"
  "is_external BOOLEAN NOT NULL,"
14 15
  "FOREIGN KEY (media_id) REFERENCES " + Media::Table::Name + "(id_media) ON DELETE CASCADE,"
  "FOREIGN KEY (folder_id) REFERENCES " + Folder::Table::Name + "(id_folder) ON DELETE CASCADE,"
16 17
  "UNIQUE( mrl, folder_id ) ON CONFLICT FAIL);",

18
"INSERT INTO " + File::Table::Name + "_backup SELECT * FROM " + File::Table::Name + ";",
19

20
"DROP TABLE " + File::Table::Name + ";",
21

22
"CREATE TABLE " + File::Table::Name + "(id_file INTEGER PRIMARY KEY AUTOINCREMENT,"
23 24 25 26 27 28 29 30 31 32 33 34
                  "media_id UNSIGNED INT DEFAULT NULL,"
                  "playlist_id UNSIGNED INT DEFAULT NULL," // Added
                  "mrl TEXT,"
                  "type UNSIGNED INTEGER,"
                  "last_modification_date UNSIGNED INT,"
                  "size UNSIGNED INT,"
                  "parser_step INTEGER NOT NULL DEFAULT 0,"
                  "parser_retries INTEGER NOT NULL DEFAULT 0,"
                  "folder_id UNSIGNED INTEGER,"
                  "is_present BOOLEAN NOT NULL DEFAULT 1,"
                  "is_removable BOOLEAN NOT NULL,"
                  "is_external BOOLEAN NOT NULL,"
35 36 37
  "FOREIGN KEY (media_id) REFERENCES " + Media::Table::Name + "(id_media) ON DELETE CASCADE,"
  "FOREIGN KEY (playlist_id) REFERENCES " + Playlist::Table::Name + "(id_playlist) ON DELETE CASCADE," // Added
  "FOREIGN KEY (folder_id) REFERENCES " + Folder::Table::Name + "(id_folder) ON DELETE CASCADE,"
38 39
  "UNIQUE( mrl, folder_id ) ON CONFLICT FAIL);",

40 41
"INSERT INTO " + File::Table::Name + "(id_file,media_id,mrl,type,last_modification_date,size,parser_step,parser_retries,folder_id,is_present,is_removable,is_external)"
 " SELECT * FROM " + File::Table::Name + "_backup;",
42

43
"DROP TABLE " + File::Table::Name + "_backup;",
44

45
"CREATE TEMPORARY TABLE " + Playlist::Table::Name + "_backup("
46 47 48 49
  "id_playlist INTEGER PRIMARY KEY AUTOINCREMENT,"
  "name TEXT UNIQUE,"
  "creation_date UNSIGNED INT NOT NULL);",

50
"INSERT INTO " + Playlist::Table::Name + "_backup SELECT * FROM Playlist;",
51

52
"DROP TABLE " + Playlist::Table::Name + ";",
53

54
"CREATE TABLE " + Playlist::Table::Name + "("
55 56 57 58 59
  "id_playlist INTEGER PRIMARY KEY AUTOINCREMENT,"
  "name TEXT UNIQUE,"
  "file_id UNSIGNED INT DEFAULT NULL," // Added
  "creation_date UNSIGNED INT NOT NULL,"
  "artwork_mrl TEXT," // Added
60
  "FOREIGN KEY (file_id) REFERENCES " + File::Table::Name + "(id_file) ON DELETE CASCADE);", // Added
61

62 63
"INSERT INTO " + Playlist::Table::Name + "(id_playlist,name,creation_date)"
 " SELECT * FROM " + Playlist::Table::Name + "_backup;",
64

65
"DROP TABLE " + Playlist::Table::Name + "_backup;",