Fix db upgrade from 12 -> 13

This commit is contained in:
Ron Pedde 2006-11-19 18:58:03 +00:00
parent 4d8e618f75
commit d5506fc46f
4 changed files with 31 additions and 28 deletions

View File

@ -65,7 +65,7 @@
<short_description>
Should the logfile get truncated on startup?
</short_description>
<type default_value="1">select</type>
<type default_value="0">select</type>
<options>
<option value="0">No</option>
<option value="1">Yes</option>

View File

@ -126,6 +126,7 @@ static CONF_ELEMENTS conf_elements[] = {
{ 0, 0, CONF_T_STRING,"general","never_transcode" },
{ 0, 0, CONF_T_MULTICOMMA,"general","compdirs" },
{ 0, 0, CONF_T_STRING,"general","logfile" },
{ 0, 0, CONF_T_INT,"general","truncate" },
{ 0, 0, CONF_T_EXISTPATH,"plugins","plugin_dir" },
{ 0, 0, CONF_T_MULTICOMMA,"plugins","plugins" },
{ 0, 0, CONF_T_INT,"daap","empty_strings" },

View File

@ -69,7 +69,7 @@ static char *db_sqlite2_enum_query;
static char db_sqlite2_path[PATH_MAX + 1];
#define DB_SQLITE2_VERSION 12
#define DB_SQLITE2_VERSION 13
/* Forwards */
@ -157,7 +157,8 @@ int db_sqlite2_open(char **pe, char *dsn) {
DPRINTF(E_LOG,L_DB,"Can't get db version. New database?\n");
} else if(ver != DB_SQLITE2_VERSION) {
/* we'll deal with this in the db handler */
DPRINTF(E_LOG,L_DB,"Old database version.\n");
DPRINTF(E_LOG,L_DB,"Old database version: %d, expecting %d\n",
ver, DB_SQLITE2_VERSION);
db_get_error(pe,DB_E_WRONGVERSION);
return DB_E_WRONGVERSION;
}
@ -328,13 +329,13 @@ int db_sqlite2_event(int event_type) {
if(!conf_get_int("database","quick_startup",0))
db_sqlite2_exec(NULL,E_FATAL,"vacuum");
/* make sure our indexes exist */
db_sqlite2_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
/* make sure our indexes exist */
db_sqlite2_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite2_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite2_reload=0;
break;

View File

@ -152,7 +152,8 @@ 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_LOG,L_DB,"Old database version.\n");
DPRINTF(E_LOG,L_DB,"Old database version: %d, expecting %d\n",
ver,DB_SQLITE3_VERSION);
db_get_error(pe,DB_E_WRONGVERSION);
return DB_E_WRONGVERSION;
}
@ -362,12 +363,12 @@ int db_sqlite3_event(int event_type) {
if(!conf_get_int("database","quick_startup",0))
db_sqlite3_exec(NULL,E_FATAL,"vacuum");
db_sqlite3_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_path on "
"songs(path,idx)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_songid on "
"playlistitems(songid)");
db_sqlite3_exec(NULL,E_DBG,"create index idx_playlistid on "
"playlistitems(playlistid,songid)");
db_sqlite3_reload=0;
break;