Akonadi
dbinitializer.cpp
146 const QList<DbIntrospector::ForeignKey> existingForeignKeys = m_introspector->foreignKeyConstraints(tableDescription.name);
159 if (QString::compare(existingForeignKey.refTable, column.refTable + QLatin1StringView("table"), Qt::CaseInsensitive) == 0
161 && QString::compare(existingForeignKey.onUpdate, referentialActionToString(column.onUpdate), Qt::CaseInsensitive) == 0
162 && QString::compare(existingForeignKey.onDelete, referentialActionToString(column.onDelete), Qt::CaseInsensitive) == 0) {
166 const auto statements = buildRemoveForeignKeyConstraintStatements(existingForeignKey, tableDescription);
168 qCDebug(AKONADISERVER_LOG) << "Found existing foreign constraint that doesn't match the schema:" << existingForeignKey.name
183 const auto statements = buildRemoveForeignKeyConstraintStatements(existingForeignKey, tableDescription);
185 qCDebug(AKONADISERVER_LOG) << "Found unexpected foreign key constraint:" << existingForeignKey.name << existingForeignKey.column
201 const QString indexName = QStringLiteral("%1_%2").arg(tableDescription.name, indexDescription.name);
301 if (col.type == QLatin1StringView("QDateTime") && value == QLatin1StringView("QDateTime::currentDateTimeUtc()")) {
309QString DbInitializer::buildAddColumnStatement(const TableDescription &tableDescription, const ColumnDescription &columnDescription) const
311 return QStringLiteral("ALTER TABLE %1 ADD COLUMN %2").arg(tableDescription.name, buildColumnStatement(columnDescription, tableDescription));
314QString DbInitializer::buildCreateIndexStatement(const TableDescription &tableDescription, const IndexDescription &indexDescription) const
316 const QString indexName = QStringLiteral("%1_%2").arg(tableDescription.name, indexDescription.name);
331 .arg(indexDescription.isUnique ? QStringLiteral("UNIQUE") : QString(), indexName, tableDescription.name, columns.join(QLatin1Char(',')));
334QStringList DbInitializer::buildAddForeignKeyConstraintStatements(const TableDescription &table, const ColumnDescription &column) const
341QStringList DbInitializer::buildRemoveForeignKeyConstraintStatements(const DbIntrospector::ForeignKey &fk, const TableDescription &table) const
348QString DbInitializer::buildReferentialAction(ColumnDescription::ReferentialAction onUpdate, ColumnDescription::ReferentialAction onDelete)
350 return QLatin1StringView("ON UPDATE ") + referentialActionToString(onUpdate) + QLatin1StringView(" ON DELETE ") + referentialActionToString(onDelete);
376 return QLatin1StringView("PRIMARY KEY (") + cols.join(QLatin1StringView(", ")) + QLatin1Char(')');
A helper class that describes a column of a table for the DbInitializer.
Definition schematypes.h:23
A helper class that describes the predefined data of a table for the DbInitializer.
Definition schematypes.h:65
static DataStore * dataStoreForDatabase(const QSqlDatabase &db)
Returns DataStore associated with the given database connection.
Definition datastore.cpp:94
static DbInitializer::Ptr createInstance(const QSqlDatabase &database, Schema *schema=nullptr)
Returns an initializer instance for a given backend.
Definition dbinitializer.cpp:27
virtual QStringList buildRemoveForeignKeyConstraintStatements(const DbIntrospector::ForeignKey &fk, const TableDescription &table) const
Returns an SQL statements to remove the foreign key constraint fk from table table.
Definition dbinitializer.cpp:341
virtual QString sqlValue(const ColumnDescription &col, const QString &value) const
Overwrite in backend-specific sub-classes to return the SQL value for a given C++ value.
Definition dbinitializer.cpp:299
DbInitializer(const QSqlDatabase &database)
Creates a new database initializer.
Definition dbinitializer.cpp:48
virtual QString sqlType(const ColumnDescription &col, int size) const
Overwrite in backend-specific sub-classes to return the SQL type for a given C++ type.
Definition dbinitializer.cpp:269
QString errorMsg() const
Returns the textual description of an occurred error.
Definition dbinitializer.cpp:214
virtual QStringList buildAddForeignKeyConstraintStatements(const TableDescription &table, const ColumnDescription &column) const
Returns an SQL statements to add a foreign key constraint to an existing column column.
Definition dbinitializer.cpp:334
bool updateIndexesAndConstraints()
Checks and creates missing indexes.
Definition dbinitializer.cpp:219
virtual QString buildCreateTableStatement(const TableDescription &tableDescription) const =0
Returns a backend-specific CREATE TABLE SQL query describing given table.
static QString buildPrimaryKeyStatement(const TableDescription &table)
Use for multi-column primary keys during table creation.
Definition dbinitializer.cpp:368
A structure describing an existing foreign key.
Definition dbintrospector.h:31
static DbIntrospector::Ptr createInstance(const QSqlDatabase &database)
Returns an introspector instance for a given database.
Definition dbintrospector.cpp:22
A helper class that describes indexes of a table for the DbInitializer.
Definition schematypes.h:53
A helper class that describes the relation between two tables for the DbInitializer.
Definition schematypes.h:91
TableDescription constructed based on RelationDescription.
Definition schematypes.h:104
virtual QList< RelationDescription > relations()=0
List of relations (N:M helper tables) in the schema.
virtual QList< TableDescription > tables()=0
List of tables in the schema.
A helper class that describes a table for the DbInitializer.
Definition schematypes.h:77
Type type(const QSqlDatabase &db)
Returns the type of the given database object.
Definition dbtype.cpp:11
QDateTime currentDateTimeUtc()
const_iterator cbegin() const const
const_iterator cend() const const
void clear()
qsizetype count() const const
bool isEmpty() const const
void push_back(parameter_type value)
void reserve(qsizetype size)
QString driverName() const const
QString arg(Args &&... args) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QString fromUtf8(QByteArrayView str)
bool isEmpty() const const
QString number(double n, char format, int precision)
QString join(QChar separator) const const
CaseInsensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.