Huge fixes for MySQL backend.

This commit is contained in:
Martin Rotter 2020-10-25 14:04:20 +01:00
parent 5821d87a85
commit 1618562295
16 changed files with 35 additions and 5 deletions

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS GmailAccounts (
id INTEGER,
username TEXT NOT NULL,

View File

@ -1,3 +1,5 @@
USE ##;
-- !
ALTER TABLE Feeds
MODIFY url VARCHAR(1000);
-- !

View File

@ -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);
-- !

View File

@ -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);
-- !

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS MessageFilters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS Labels (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),

View File

@ -1,3 +1,5 @@
USE ##;
-- !
SET FOREIGN_KEY_CHECKS = 0;
-- !
ALTER TABLE Labels MODIFY id INTEGER AUTO_INCREMENT;

View File

@ -1,3 +1,5 @@
USE ##;
-- !
ALTER TABLE Messages
ADD COLUMN enclosures TEXT;
-- !

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE Accounts (
id INTEGER PRIMARY KEY,
type TEXT NOT NULL

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS OwnCloudAccounts (
id INTEGER,
username TEXT NOT NULL,

View File

@ -1,3 +1,5 @@
USE ##;
-- !
ALTER TABLE Messages
ADD COLUMN custom_hash TEXT;
-- !

View File

@ -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;

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS Labels (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
account_id INTEGER NOT NULL,

View File

@ -1,3 +1,5 @@
USE ##;
-- !
ALTER TABLE OwnCloudAccounts
ADD COLUMN msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1);
-- !

View File

@ -1,3 +1,5 @@
USE ##;
-- !
CREATE TABLE IF NOT EXISTS InoreaderAccounts (
id INTEGER,
username TEXT NOT NULL,

View File

@ -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 '"