Akonadi

schematypes.cpp
1/***************************************************************************
2 * SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org> *
3 * SPDX-FileCopyrightText: 2013 Volker Krause <vkrause@kde.org> *
4 * *
5 * SPDX-License-Identifier: LGPL-2.0-or-later *
6 ***************************************************************************/
7
8#include "schematypes.h"
9
10#include <algorithm>
11
12using namespace Akonadi::Server;
13
14int TableDescription::primaryKeyColumnCount() const
15{
16 return std::count_if(columns.constBegin(), columns.constEnd(), [](const ColumnDescription &col) {
17 return col.isPrimaryKey;
18 });
19}
20
21RelationTableDescription::RelationTableDescription(const RelationDescription &relation)
23{
24 name = relation.firstTable + relation.secondTable + QStringLiteral("Relation");
25
26 columns = {ColumnDescription{.name = QStringLiteral("%1_%2").arg(relation.firstTable, relation.firstColumn),
27 .type = QStringLiteral("qint64"),
28 .allowNull = false,
29 .isPrimaryKey = true,
30 .refTable = relation.firstTable,
31 .refColumn = relation.firstColumn},
32 ColumnDescription{.name = QStringLiteral("%1_%2").arg(relation.secondTable, relation.secondColumn),
33 .type = QStringLiteral("qint64"),
34 .allowNull = false,
35 .isPrimaryKey = true,
36 .refTable = relation.secondTable,
37 .refColumn = relation.secondColumn}};
38 indexes = {IndexDescription{.name = QStringLiteral("%1Index").arg(columns[0].name), .columns = {columns[0].name}, .isUnique = false},
39 IndexDescription{.name = QStringLiteral("%1Index").arg(columns[1].name), .columns = {columns[1].name}, .isUnique = false}};
40 indexes += relation.indexes;
41}
A helper class that describes a column of a table for the DbInitializer.
Definition schematypes.h:23
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
A helper class that describes a table for the DbInitializer.
Definition schematypes.h:77
QString name(StandardAction id)
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

KDE's Doxygen guidelines are available online.