Check database version first, if that fails, try DB init

Doing it the other way around is a guaranteed way to run into issues when
a schema upgrade is needed.
This commit is contained in:
Julien BLACHE 2010-01-21 17:51:00 +01:00
parent 87abc3f432
commit 944bf3f132

View File

@ -3140,6 +3140,11 @@ db_init(void)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = db_check_version();
if (ret < 0)
{
DPRINTF(E_FATAL, L_DB, "Could not check database version, trying DB init\n");
ret = db_create_tables(); ret = db_create_tables();
if (ret < 0) if (ret < 0)
{ {
@ -3147,13 +3152,6 @@ db_init(void)
db_perthread_deinit(); db_perthread_deinit();
return -1; return -1;
} }
ret = db_check_version();
if (ret < 0)
{
DPRINTF(E_FATAL, L_DB, "Could not check database version\n");
db_perthread_deinit();
return -1;
} }
files = db_files_get_count(); files = db_files_get_count();