mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-27 07:46:19 +01:00
Fix DB schema
This commit is contained in:
parent
41b0b1efd4
commit
3b30e66e87
@ -1,8 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS schema_version (
|
||||
version INTEGER NOT NULL
|
||||
);
|
||||
|
||||
DELETE FROM schema_version;
|
||||
REPLACE INTO schema_version (version) VALUES (1);
|
||||
|
||||
INSERT INTO schema_version (version) VALUES (1);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS directories (
|
||||
path TEXT NOT NULL,
|
||||
|
@ -436,12 +436,14 @@ void Database::DetachDatabase(const QString &database_name) {
|
||||
}
|
||||
|
||||
void Database::UpdateDatabaseSchema(int version, QSqlDatabase &db) {
|
||||
|
||||
|
||||
QString filename;
|
||||
if (version == 0) filename = ":/schema/schema.sql";
|
||||
else filename = QString(":/schema/schema-%1.sql").arg(version);
|
||||
else {
|
||||
filename = QString(":/schema/schema-%1.sql").arg(version);
|
||||
qLog(Debug) << "Applying database schema update" << version << "from" << filename;
|
||||
}
|
||||
|
||||
qLog(Debug) << "Applying database schema update" << version << "from" << filename;
|
||||
ExecSchemaCommandsFromFile(db, filename, version - 1);
|
||||
|
||||
}
|
||||
@ -474,7 +476,7 @@ void Database::UrlEncodeFilenameColumn(const QString &table, QSqlDatabase &db) {
|
||||
}
|
||||
|
||||
void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filename, int schema_version, bool in_transaction) {
|
||||
|
||||
|
||||
// Open and read the database schema
|
||||
QFile schema_file(filename);
|
||||
if (!schema_file.open(QIODevice::ReadOnly))
|
||||
|
Loading…
x
Reference in New Issue
Block a user