Akonadi::Server::DbInitializer
#include <dbinitializer.h>
Public Types | |
using | Ptr = QSharedPointer<DbInitializer> |
Public Member Functions | |
virtual | ~DbInitializer () |
virtual QString | buildCreateTableStatement (const TableDescription &tableDescription) const =0 |
QString | errorMsg () const |
bool | run () |
bool | updateIndexesAndConstraints () |
Static Public Member Functions | |
static DbInitializer::Ptr | createInstance (const QSqlDatabase &database, Schema *schema=nullptr) |
Protected Member Functions | |
DbInitializer (const QSqlDatabase &database) | |
virtual QString | buildAddColumnStatement (const TableDescription &tableDescription, const ColumnDescription &columnDescription) const |
virtual QStringList | buildAddForeignKeyConstraintStatements (const TableDescription &table, const ColumnDescription &column) const |
virtual QString | buildColumnStatement (const ColumnDescription &columnDescription, const TableDescription &tableDescription) const =0 |
virtual QString | buildCreateIndexStatement (const TableDescription &tableDescription, const IndexDescription &indexDescription) const |
virtual QString | buildInsertValuesStatement (const TableDescription &tableDescription, const DataDescription &dataDescription) const =0 |
virtual QStringList | buildRemoveForeignKeyConstraintStatements (const DbIntrospector::ForeignKey &fk, const TableDescription &table) const |
virtual QString | sqlType (const ColumnDescription &col, int size) const |
virtual QString | sqlValue (const ColumnDescription &col, const QString &value) const |
Static Protected Member Functions | |
static QString | buildPrimaryKeyStatement (const TableDescription &table) |
static QString | buildReferentialAction (ColumnDescription::ReferentialAction onUpdate, ColumnDescription::ReferentialAction onDelete) |
Detailed Description
A helper class which takes a reference to a database object and the file name of a template file and initializes the database according to the rules in the template file.
TODO: Refactor this to be easily reusable for updater too
Definition at line 47 of file dbinitializer.h.
Member Typedef Documentation
◆ Ptr
Definition at line 52 of file dbinitializer.h.
Constructor & Destructor Documentation
◆ ~DbInitializer()
|
virtual |
Destroys the database initializer.
Definition at line 56 of file dbinitializer.cpp.
◆ DbInitializer()
|
protected |
Creates a new database initializer.
- Parameters
-
database The reference to the database.
Definition at line 48 of file dbinitializer.cpp.
Member Function Documentation
◆ buildAddColumnStatement()
|
protectedvirtual |
Definition at line 309 of file dbinitializer.cpp.
◆ buildAddForeignKeyConstraintStatements()
|
protectedvirtual |
Returns an SQL statements to add a foreign key constraint to an existing column column
.
The default implementation returns an empty string, so any backend supporting foreign key constraints must reimplement this.
Definition at line 334 of file dbinitializer.cpp.
◆ buildCreateIndexStatement()
|
protectedvirtual |
Definition at line 314 of file dbinitializer.cpp.
◆ buildCreateTableStatement()
|
pure virtual |
Returns a backend-specific CREATE TABLE SQL query describing given table.
◆ buildPrimaryKeyStatement()
|
staticprotected |
Use for multi-column primary keys during table creation.
Definition at line 368 of file dbinitializer.cpp.
◆ buildReferentialAction()
|
staticprotected |
Definition at line 348 of file dbinitializer.cpp.
◆ buildRemoveForeignKeyConstraintStatements()
|
protectedvirtual |
Returns an SQL statements to remove the foreign key constraint fk
from table table
.
The default implementation returns an empty string, so any backend supporting foreign key constraints must reimplement this.
Definition at line 341 of file dbinitializer.cpp.
◆ createInstance()
|
static |
Returns an initializer instance for a given backend.
Definition at line 27 of file dbinitializer.cpp.
◆ errorMsg()
QString DbInitializer::errorMsg | ( | ) | const |
Returns the textual description of an occurred error.
Definition at line 214 of file dbinitializer.cpp.
◆ run()
bool DbInitializer::run | ( | ) |
Starts the initialization process.
On success true is returned, false otherwise.
If something went wrong
- See also
- errorMsg() can be used to retrieve more information.
Definition at line 60 of file dbinitializer.cpp.
◆ sqlType()
|
protectedvirtual |
Overwrite in backend-specific sub-classes to return the SQL type for a given C++ type.
- Parameters
-
type Name of the C++ type. size Optional size hint for the column, if -1 use the default SQL type for type
.
Definition at line 269 of file dbinitializer.cpp.
◆ sqlValue()
|
protectedvirtual |
Overwrite in backend-specific sub-classes to return the SQL value for a given C++ value.
Definition at line 299 of file dbinitializer.cpp.
◆ updateIndexesAndConstraints()
bool DbInitializer::updateIndexesAndConstraints | ( | ) |
Checks and creates missing indexes.
This method is run after DbUpdater to ensure that data in new columns are populated and creation of indexes and foreign keys does not fail.
Definition at line 219 of file dbinitializer.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.