diff --git a/resources/sql/db_update_mysql_10_11.sql b/resources/sql/db_update_mysql_10_11.sql index 90521b49b..042263f71 100755 --- a/resources/sql/db_update_mysql_10_11.sql +++ b/resources/sql/db_update_mysql_10_11.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS GmailAccounts ( id INTEGER, username TEXT NOT NULL, diff --git a/resources/sql/db_update_mysql_11_12.sql b/resources/sql/db_update_mysql_11_12.sql index 5948efd97..06175c33e 100644 --- a/resources/sql/db_update_mysql_11_12.sql +++ b/resources/sql/db_update_mysql_11_12.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE Feeds MODIFY url VARCHAR(1000); -- ! diff --git a/resources/sql/db_update_mysql_12_13.sql b/resources/sql/db_update_mysql_12_13.sql index ec44aca6d..370aec9cf 100755 --- a/resources/sql/db_update_mysql_12_13.sql +++ b/resources/sql/db_update_mysql_12_13.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE TtRssAccounts ADD COLUMN update_only_unread INTEGER(1) NOT NULL DEFAULT 0 CHECK (update_only_unread >= 0 AND update_only_unread <= 1); -- ! diff --git a/resources/sql/db_update_mysql_13_14.sql b/resources/sql/db_update_mysql_13_14.sql index 5fbbde118..215a2367b 100755 --- a/resources/sql/db_update_mysql_13_14.sql +++ b/resources/sql/db_update_mysql_13_14.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE OwnCloudAccounts ADD COLUMN update_only_unread INTEGER(1) NOT NULL DEFAULT 0 CHECK (update_only_unread >= 0 AND update_only_unread <= 1); -- ! diff --git a/resources/sql/db_update_mysql_14_15.sql b/resources/sql/db_update_mysql_14_15.sql index ec7275f3b..2abe38cf2 100755 --- a/resources/sql/db_update_mysql_14_15.sql +++ b/resources/sql/db_update_mysql_14_15.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS MessageFilters ( id INTEGER PRIMARY KEY, name TEXT NOT NULL CHECK (name != ''), diff --git a/resources/sql/db_update_mysql_15_16.sql b/resources/sql/db_update_mysql_15_16.sql index f42d89d82..65a22ec05 100644 --- a/resources/sql/db_update_mysql_15_16.sql +++ b/resources/sql/db_update_mysql_15_16.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS Labels ( id INTEGER PRIMARY KEY, name TEXT NOT NULL CHECK (name != ''), diff --git a/resources/sql/db_update_mysql_16_17.sql b/resources/sql/db_update_mysql_16_17.sql index 7891d47a8..d6c3afe99 100644 --- a/resources/sql/db_update_mysql_16_17.sql +++ b/resources/sql/db_update_mysql_16_17.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! SET FOREIGN_KEY_CHECKS = 0; -- ! ALTER TABLE Labels MODIFY id INTEGER AUTO_INCREMENT; diff --git a/resources/sql/db_update_mysql_2_3.sql b/resources/sql/db_update_mysql_2_3.sql index 326b083b8..e0b41fb21 100644 --- a/resources/sql/db_update_mysql_2_3.sql +++ b/resources/sql/db_update_mysql_2_3.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE Messages ADD COLUMN enclosures TEXT; -- ! diff --git a/resources/sql/db_update_mysql_3_4.sql b/resources/sql/db_update_mysql_3_4.sql index bb60d6105..4338dbd6d 100644 --- a/resources/sql/db_update_mysql_3_4.sql +++ b/resources/sql/db_update_mysql_3_4.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE Accounts ( id INTEGER PRIMARY KEY, type TEXT NOT NULL diff --git a/resources/sql/db_update_mysql_4_5.sql b/resources/sql/db_update_mysql_4_5.sql index 44f7af0a6..2e99e3add 100755 --- a/resources/sql/db_update_mysql_4_5.sql +++ b/resources/sql/db_update_mysql_4_5.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS OwnCloudAccounts ( id INTEGER, username TEXT NOT NULL, diff --git a/resources/sql/db_update_mysql_5_6.sql b/resources/sql/db_update_mysql_5_6.sql index d7d6553fe..6ab572b78 100755 --- a/resources/sql/db_update_mysql_5_6.sql +++ b/resources/sql/db_update_mysql_5_6.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE Messages ADD COLUMN custom_hash TEXT; -- ! diff --git a/resources/sql/db_update_mysql_6_7.sql b/resources/sql/db_update_mysql_6_7.sql index 3377699a9..ac8a0a715 100755 --- a/resources/sql/db_update_mysql_6_7.sql +++ b/resources/sql/db_update_mysql_6_7.sql @@ -3,18 +3,18 @@ ALTER DATABASE ## CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; -- ! -USE ## +USE ##; -- ! -ALTER TABLE messages +ALTER TABLE Messages CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- ! -ALTER TABLE messages +ALTER TABLE Messages CHANGE title title TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- ! -ALTER TABLE messages +ALTER TABLE Messages CHANGE contents contents TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/resources/sql/db_update_mysql_7_8.sql b/resources/sql/db_update_mysql_7_8.sql index ab59d647e..51f6b37b3 100755 --- a/resources/sql/db_update_mysql_7_8.sql +++ b/resources/sql/db_update_mysql_7_8.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS Labels ( id INTEGER AUTO_INCREMENT PRIMARY KEY, account_id INTEGER NOT NULL, diff --git a/resources/sql/db_update_mysql_8_9.sql b/resources/sql/db_update_mysql_8_9.sql index d9d6c486c..56df55084 100755 --- a/resources/sql/db_update_mysql_8_9.sql +++ b/resources/sql/db_update_mysql_8_9.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! ALTER TABLE OwnCloudAccounts ADD COLUMN msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1); -- ! diff --git a/resources/sql/db_update_mysql_9_10.sql b/resources/sql/db_update_mysql_9_10.sql index c8694580d..b0ba87066 100755 --- a/resources/sql/db_update_mysql_9_10.sql +++ b/resources/sql/db_update_mysql_9_10.sql @@ -1,3 +1,5 @@ +USE ##; +-- ! CREATE TABLE IF NOT EXISTS InoreaderAccounts ( id INTEGER, username TEXT NOT NULL, diff --git a/src/librssguard/miscellaneous/databasefactory.cpp b/src/librssguard/miscellaneous/databasefactory.cpp index 568598150..2d7591a71 100644 --- a/src/librssguard/miscellaneous/databasefactory.cpp +++ b/src/librssguard/miscellaneous/databasefactory.cpp @@ -498,6 +498,8 @@ bool DatabaseFactory::mysqlUpdateDatabaseSchema(const QSqlDatabase& database, QSqlQuery query = database.exec(statement.replace(APP_DB_NAME_PLACEHOLDER, db_name)); if (query.lastError().isValid()) { + auto xx = query.lastError().text(); + qFatal("Query for updating database schema failed: '%s'.", qPrintable(query.lastError().text())); } } @@ -772,7 +774,7 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_ query_db.next(); const QString installed_db_schema = query_db.value(0).toString(); - if (installed_db_schema < APP_DB_SCHEMA_VERSION) { + if (installed_db_schema.toInt() < QString(APP_DB_SCHEMA_VERSION).toInt()) { if (mysqlUpdateDatabaseSchema(database, installed_db_schema, database_name)) { qDebugNN << LOGSEC_DB << "Database schema was updated from '"