diff --git a/resources/sql/db_init_mysql.sql b/resources/sql/db_init_mysql.sql index 572da652d..d9858848d 100644 --- a/resources/sql/db_init_mysql.sql +++ b/resources/sql/db_init_mysql.sql @@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS OwnCloudAccounts ( password TEXT, url TEXT NOT NULL, force_update INTEGER(1) NOT NULL DEFAULT 0 CHECK (force_update >= 0 AND force_update <= 1), + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), FOREIGN KEY (id) REFERENCES Accounts (id) ); diff --git a/resources/sql/db_init_sqlite.sql b/resources/sql/db_init_sqlite.sql index 0eaa093ac..625ffb41a 100644 --- a/resources/sql/db_init_sqlite.sql +++ b/resources/sql/db_init_sqlite.sql @@ -32,6 +32,7 @@ CREATE TABLE IF NOT EXISTS OwnCloudAccounts ( password TEXT, url TEXT NOT NULL, force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), FOREIGN KEY (id) REFERENCES Accounts (id) ); diff --git a/resources/sql/db_update_mysql_8_9.sql b/resources/sql/db_update_mysql_8_9.sql new file mode 100755 index 000000000..21aa8b282 --- /dev/null +++ b/resources/sql/db_update_mysql_8_9.sql @@ -0,0 +1,4 @@ +ALTER TABLE OwnCloudAccounts +ADD COLUMN msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1); +-- ! +UPDATE Information SET inf_value = '9' WHERE inf_key = 'schema_version'; \ No newline at end of file diff --git a/resources/sql/db_update_sqlite_8_9.sql b/resources/sql/db_update_sqlite_8_9.sql new file mode 100755 index 000000000..df9372f00 --- /dev/null +++ b/resources/sql/db_update_sqlite_8_9.sql @@ -0,0 +1,21 @@ +CREATE TABLE backup_oa AS SELECT * FROM OwnCloudAccounts; +-- ! +DROP TABLE OwnCloudAccounts; +-- ! +CREATE TABLE IF NOT EXISTS OwnCloudAccounts ( + id INTEGER, + username TEXT NOT NULL, + password TEXT, + url TEXT NOT NULL, + force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), + + FOREIGN KEY (id) REFERENCES Accounts (id) +); +-- ! +INSERT INTO OwnCloudAccounts (id, username, password, url, force_update) +SELECT id, username, password, url, force_update FROM backup_oa; +-- ! +DROP TABLE backup_oa; +-- ! +UPDATE Information SET inf_value = '9' WHERE inf_key = 'schema_version'; \ No newline at end of file diff --git a/src/definitions/definitions.h b/src/definitions/definitions.h index 0fb237ac7..9bcf30076 100755 --- a/src/definitions/definitions.h +++ b/src/definitions/definitions.h @@ -121,7 +121,7 @@ #define APP_DB_SQLITE_FILE "database.db" // Keep this in sync with schema versions declared in SQL initialization code. -#define APP_DB_SCHEMA_VERSION "8" +#define APP_DB_SCHEMA_VERSION "9" #define APP_DB_UPDATE_FILE_PATTERN "db_update_%1_%2_%3.sql" #define APP_DB_COMMENT_SPLIT "-- !\n" #define APP_DB_NAME_PLACEHOLDER "##" diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index 913b580d3..138a606f1 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -342,7 +342,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c const QString installed_db_schema = query_db.value(0).toString(); query_db.finish(); - if (installed_db_schema < APP_DB_SCHEMA_VERSION) { + if (installed_db_schema.toInt() < QString(APP_DB_SCHEMA_VERSION).toInt()) { if (sqliteUpdateDatabaseSchema(database, installed_db_schema)) { qDebug("Database schema was updated from '%s' to '%s' successully or it is already up to date.", qPrintable(installed_db_schema),