Preserve playlists on db upgrades

This commit is contained in:
Ron Pedde 2006-01-12 06:20:15 +00:00
parent cb4de841ee
commit 40ab6dfb01
2 changed files with 14 additions and 4 deletions

View File

@ -145,7 +145,11 @@ int db_sqlite2_open(char **pe, char *dsn) {
/* we'll catch this on the init */
DPRINTF(E_LOG,L_DB,"Can't get db version. New database?\n");
} else if(ver != DB_SQLITE2_VERSION) {
DPRINTF(E_FATAL,L_DB,"Can't upgrade database!\n");
DPRINTF(E_LOG,L_DB,"Old database version -- forcing rescan\n");
err=db_sqlite2_exec(pe,E_FATAL,"insert into config (term,value) values "
"('rescan','1')");
if(err != DB_E_SUCCESS)
return err;
}
return DB_E_SUCCESS;
@ -320,7 +324,8 @@ int db_sqlite2_event(int event_type) {
db_sqlite2_exec(NULL,E_DBG,"drop index idx_playlistid");
db_sqlite2_exec(NULL,E_DBG,"drop table songs");
db_sqlite2_exec(NULL,E_DBG,"drop table playlists");
// db_sqlite2_exec(NULL,E_DBG,"drop table playlists");
db_sqlite2_exec(NULL,E_DBG,"delete from playlists where not type=1");
db_sqlite2_exec(NULL,E_DBG,"drop table playlistitems");
db_sqlite2_exec(NULL,E_DBG,"drop table config");

View File

@ -143,7 +143,11 @@ int db_sqlite3_open(char **pe, char *dsn) {
/* we'll catch this on the init */
DPRINTF(E_LOG,L_DB,"Can't get db version. New database?\n");
} else if(ver != DB_SQLITE3_VERSION) {
DPRINTF(E_FATAL,L_DB,"Can't upgrade database!\n");
DPRINTF(E_LOG,L_DB,"Old database version -- forcing rescan\n");
err=db_sqlite3_exec(pe,E_FATAL,"insert into config (term,value) values "
"('rescan','1')");
if(err != DB_E_SUCCESS)
return err;
}
return DB_E_SUCCESS;
@ -341,7 +345,8 @@ int db_sqlite3_event(int event_type) {
db_sqlite3_exec(NULL,E_DBG,"drop index idx_playlistid");
db_sqlite3_exec(NULL,E_DBG,"drop table songs");
db_sqlite3_exec(NULL,E_DBG,"drop table playlists");
// db_sqlite3_exec(NULL,E_DBG,"drop table playlists");
db_sqlite3_exec(NULL,E_DBG,"delete from playlists where not type=1");
db_sqlite3_exec(NULL,E_DBG,"drop table playlistitems");
db_sqlite3_exec(NULL,E_DBG,"drop table config");