diff --git a/src/db-sql-sqlite2.c b/src/db-sql-sqlite2.c index 6957df01..c5c464ac 100644 --- a/src/db-sql-sqlite2.c +++ b/src/db-sql-sqlite2.c @@ -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"); diff --git a/src/db-sql-sqlite3.c b/src/db-sql-sqlite3.c index 54a56797..d744566a 100644 --- a/src/db-sql-sqlite3.c +++ b/src/db-sql-sqlite3.c @@ -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");