1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-02-03 12:47:31 +01:00

Always create the schema in external databases if it doesn't exist yet. Fixes issue #1034

This commit is contained in:
David Sansome 2010-12-07 19:07:12 +00:00
parent 6a27020ccd
commit 8aa7973312

View File

@ -441,6 +441,19 @@ QSqlDatabase Database::Connect() {
}
}
// We might have to initialise the schema in some attached databases now, if
// they were deleted and don't match up with the main schema version.
foreach (const QString& key, attached_databases_.keys()) {
// Find out if there are any tables in this database
QSqlQuery q(QString("SELECT ROWID FROM %1.sqlite_master"
" WHERE type='table'").arg(key), db);
if (!q.exec() || !q.next()) {
ScopedTransaction t(&db);
ExecFromFile(attached_databases_[key].schema_, db);
t.Commit();
}
}
return db;
}