File indexing completed on 2025-01-05 04:46:58
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> * 0003 * SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org> * 0004 * * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later * 0006 ***************************************************************************/ 0007 0008 #pragma once 0009 0010 #include "storage/dbinitializer.h" 0011 0012 namespace Akonadi 0013 { 0014 namespace Server 0015 { 0016 class DbInitializerMySql : public DbInitializer 0017 { 0018 public: 0019 explicit DbInitializerMySql(const QSqlDatabase &database); 0020 0021 protected: 0022 QString sqlType(const ColumnDescription &col, int size) const override; 0023 0024 QString buildCreateTableStatement(const TableDescription &tableDescription) const override; 0025 QString buildColumnStatement(const ColumnDescription &columnDescription, const TableDescription &tableDescription) const override; 0026 QString buildInsertValuesStatement(const TableDescription &tableDescription, const DataDescription &dataDescription) const override; 0027 QStringList buildAddForeignKeyConstraintStatements(const TableDescription &table, const ColumnDescription &column) const override; 0028 QStringList buildRemoveForeignKeyConstraintStatements(const DbIntrospector::ForeignKey &fk, const TableDescription &table) const override; 0029 }; 0030 0031 class DbInitializerSqlite : public DbInitializer 0032 { 0033 public: 0034 explicit DbInitializerSqlite(const QSqlDatabase &database); 0035 0036 protected: 0037 QString buildCreateTableStatement(const TableDescription &tableDescription) const override; 0038 QString buildColumnStatement(const ColumnDescription &columnDescription, const TableDescription &tableDescription) const override; 0039 QString buildInsertValuesStatement(const TableDescription &tableDescription, const DataDescription &dataDescription) const override; 0040 QString sqlValue(const ColumnDescription &col, const QString &value) const override; 0041 QStringList buildAddForeignKeyConstraintStatements(const TableDescription &table, const ColumnDescription &column) const override; 0042 QStringList buildRemoveForeignKeyConstraintStatements(const DbIntrospector::ForeignKey &fk, const TableDescription &table) const override; 0043 0044 private: 0045 QStringList buildUpdateForeignKeyConstraintsStatements(const TableDescription &table) const; 0046 }; 0047 0048 class DbInitializerPostgreSql : public DbInitializer 0049 { 0050 public: 0051 explicit DbInitializerPostgreSql(const QSqlDatabase &database); 0052 0053 protected: 0054 QString sqlType(const ColumnDescription &col, int size) const override; 0055 0056 QString buildCreateTableStatement(const TableDescription &tableDescription) const override; 0057 QString buildColumnStatement(const ColumnDescription &columnDescription, const TableDescription &tableDescription) const override; 0058 QString buildInsertValuesStatement(const TableDescription &tableDescription, const DataDescription &dataDescription) const override; 0059 QStringList buildAddForeignKeyConstraintStatements(const TableDescription &table, const ColumnDescription &column) const override; 0060 QStringList buildRemoveForeignKeyConstraintStatements(const DbIntrospector::ForeignKey &fk, const TableDescription &table) const override; 0061 }; 0062 0063 } // namespace Server 0064 } // namespace Akonadi