save
This commit is contained in:
parent
b7ec33202c
commit
56b2b296b9
@ -6,7 +6,7 @@ CREATE TABLE Information (
|
||||
INSERT INTO Information VALUES ('schema_version', '1');
|
||||
-- !
|
||||
CREATE TABLE Accounts (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
type TEXT NOT NULL CHECK (type != ''), /* ID of the account type. Each account defines its own, for example 'ttrss'. */
|
||||
proxy_type INTEGER NOT NULL DEFAULT 0 CHECK (proxy_type >= 0),
|
||||
proxy_host TEXT,
|
||||
@ -18,7 +18,7 @@ CREATE TABLE Accounts (
|
||||
);
|
||||
-- !
|
||||
CREATE TABLE Categories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
parent_id INTEGER NOT NULL CHECK (parent_id >= -1), /* Root categories contain -1 here. */
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
@ -31,7 +31,7 @@ CREATE TABLE Categories (
|
||||
);
|
||||
-- !
|
||||
CREATE TABLE Feeds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER,
|
||||
@ -49,7 +49,7 @@ CREATE TABLE Feeds (
|
||||
);
|
||||
-- !
|
||||
CREATE TABLE Messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
||||
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
||||
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
||||
@ -70,7 +70,7 @@ CREATE TABLE Messages (
|
||||
);
|
||||
-- !
|
||||
CREATE TABLE MessageFilters (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
name TEXT NOT NULL CHECK (name != ''),
|
||||
script TEXT NOT NULL CHECK (script != '')
|
||||
);
|
||||
@ -85,7 +85,7 @@ CREATE TABLE MessageFiltersInFeeds (
|
||||
);
|
||||
-- !
|
||||
CREATE TABLE Labels (
|
||||
id INTEGER PRIMARY KEY,
|
||||
id $$,
|
||||
name TEXT NOT NULL CHECK (name != ''),
|
||||
color VARCHAR(7),
|
||||
custom_id TEXT,
|
||||
|
@ -47,5 +47,6 @@ QStringList DatabaseDriver::prepareScript(const QString& base_sql_folder,
|
||||
}
|
||||
|
||||
statements.replaceInStrings(APP_DB_NAME_PLACEHOLDER, database_name);
|
||||
statements.replaceInStrings(APP_DB_AUTO_INC_PRIM_KEY_PLACEHOLDER, autoIncrementPrimaryKey());
|
||||
return statements;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class DatabaseDriver : public QObject {
|
||||
virtual QString humanDriverType() const = 0;
|
||||
virtual QString qtDriverCode() const = 0;
|
||||
virtual DriverType driverType() const = 0;
|
||||
virtual QString autoIncrementPrimaryKey() const = 0;
|
||||
virtual bool vacuumDatabase() = 0;
|
||||
virtual bool saveDatabase() = 0;
|
||||
virtual void backupDatabase(const QString& backup_folder, const QString& backup_name) = 0;
|
||||
|
@ -296,3 +296,7 @@ QSqlDatabase MariaDbDriver::connection(const QString& connection_name, DatabaseD
|
||||
return database;
|
||||
}
|
||||
}
|
||||
|
||||
QString MariaDbDriver::autoIncrementPrimaryKey() const {
|
||||
return QSL("INTEGER AUTO_INCREMENT PRIMARY KEY");
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class MariaDbDriver : public DatabaseDriver {
|
||||
virtual qint64 databaseDataSize();
|
||||
virtual QSqlDatabase connection(const QString& connection_name,
|
||||
DatabaseDriver::DesiredStorageType desired_type = DatabaseDriver::DesiredStorageType::FromSettings);
|
||||
virtual QString autoIncrementPrimaryKey() const;
|
||||
|
||||
QString interpretErrorCode(MariaDbError error_code) const;
|
||||
|
||||
|
@ -490,3 +490,7 @@ void SqliteDriver::backupDatabase(const QString& backup_folder, const QString& b
|
||||
throw ApplicationException(tr("Database file not copied to output directory successfully."));
|
||||
}
|
||||
}
|
||||
|
||||
QString SqliteDriver::autoIncrementPrimaryKey() const {
|
||||
return QSL("INTEGER PRIMARY KEY");
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class SqliteDriver : public DatabaseDriver {
|
||||
virtual QString humanDriverType() const;
|
||||
virtual QString qtDriverCode() const;
|
||||
virtual void backupDatabase(const QString& backup_folder, const QString& backup_name);
|
||||
virtual QString autoIncrementPrimaryKey() const;
|
||||
|
||||
private:
|
||||
QSqlDatabase initializeInMemoryDatabase();
|
||||
|
@ -157,6 +157,7 @@
|
||||
#define APP_DB_COMMENT_SPLIT "-- !\n"
|
||||
#define APP_DB_INCLUDE_PLACEHOLDER "!!"
|
||||
#define APP_DB_NAME_PLACEHOLDER "##"
|
||||
#define APP_DB_AUTO_INC_PRIM_KEY_PLACEHOLDER "$$"
|
||||
|
||||
#define APP_CFG_PATH "config"
|
||||
#define APP_CFG_FILE "config.ini"
|
||||
|
Loading…
x
Reference in New Issue
Block a user