2020-03-16 22:37:04 +01:00
|
|
|
/**
|
2023-02-27 19:18:46 +01:00
|
|
|
* SPDX-FileCopyrightText: 2020 Tobias Fella <tobias.fella@kde.org>
|
2022-05-24 13:43:13 +02:00
|
|
|
* SPDX-FileCopyrightText: 2021-2022 Bart De Vries <bart@mogwai.be>
|
2020-03-16 22:37:04 +01:00
|
|
|
*
|
2020-08-14 20:56:04 +02:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2020-03-16 22:37:04 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-09-08 11:46:22 +02:00
|
|
|
#include <QObject>
|
2020-03-16 22:37:04 +01:00
|
|
|
#include <QSqlQuery>
|
2021-09-23 19:23:39 +02:00
|
|
|
#include <QString>
|
2020-03-16 22:37:04 +01:00
|
|
|
|
2020-05-26 16:32:07 +02:00
|
|
|
class Database : public QObject
|
2020-03-16 22:37:04 +01:00
|
|
|
{
|
2020-05-26 16:32:07 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2020-03-16 22:37:04 +01:00
|
|
|
public:
|
|
|
|
static Database &instance()
|
|
|
|
{
|
|
|
|
static Database _instance;
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
2022-05-24 13:43:13 +02:00
|
|
|
static void openDatabase(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
|
|
|
|
static void closeDatabase(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
|
|
|
|
|
|
|
|
static bool execute(QSqlQuery &query);
|
|
|
|
static bool execute(const QString &query, const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
|
|
|
|
|
|
|
|
static bool transaction(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
|
|
|
|
static bool commit(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
|
2021-09-23 19:23:39 +02:00
|
|
|
|
2020-03-16 22:37:04 +01:00
|
|
|
private:
|
|
|
|
Database();
|
|
|
|
int version();
|
|
|
|
|
|
|
|
bool migrate();
|
|
|
|
bool migrateTo1();
|
2021-05-14 16:46:54 +02:00
|
|
|
bool migrateTo2();
|
2021-06-23 21:11:04 +02:00
|
|
|
bool migrateTo3();
|
2021-07-14 22:27:52 +02:00
|
|
|
bool migrateTo4();
|
2021-09-21 22:36:54 +02:00
|
|
|
bool migrateTo5();
|
2021-10-29 17:00:52 +02:00
|
|
|
bool migrateTo6();
|
2023-03-14 16:17:15 +01:00
|
|
|
bool migrateTo7();
|
2023-07-05 16:03:11 +02:00
|
|
|
bool migrateTo8();
|
2023-10-26 13:19:28 +02:00
|
|
|
bool migrateTo9();
|
2020-03-26 20:24:28 +01:00
|
|
|
void cleanup();
|
2023-02-27 21:07:11 +01:00
|
|
|
void setWalMode();
|
2022-05-24 13:43:13 +02:00
|
|
|
|
|
|
|
inline static const QString m_dbName = QStringLiteral("database.db3");
|
2020-03-16 22:37:04 +01:00
|
|
|
};
|