kasts/src/database.h

53 lines
1.4 KiB
C
Raw Normal View History

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>
* 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>
#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;
}
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));
2020-03-16 22:37:04 +01:00
private:
Database();
int version();
bool migrate();
bool migrateTo1();
bool migrateTo2();
bool migrateTo3();
bool migrateTo4();
2021-09-21 22:36:54 +02:00
bool migrateTo5();
2021-10-29 17:00:52 +02:00
bool migrateTo6();
bool migrateTo7();
bool migrateTo8();
bool migrateTo9();
void cleanup();
void setWalMode();
inline static const QString m_dbName = QStringLiteral("database.db3");
2020-03-16 22:37:04 +01:00
};