File: SchemaInterface.php

package info (click to toggle)
matomo 5.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 95,068 kB
  • sloc: php: 289,425; xml: 127,249; javascript: 112,130; python: 202; sh: 178; makefile: 20; sql: 10
file content (205 lines) | stat: -rw-r--r-- 5,652 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php

/**
 * Matomo - free/libre analytics platform
 *
 * @link    https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

namespace Piwik\Db;

/**
 * Database schema interface
 */
interface SchemaInterface
{
    /**
     * Returns the type of the current database (e.g. MySQL, MariaDB, ...)
     */
    public function getDatabaseType(): string;

    /**
     * Get the SQL to create a specific Matomo table
     *
     * @param string $tableName
     * @return string  SQL
     */
    public function getTableCreateSql($tableName);

    /**
     * Get the SQL to create Matomo tables
     *
     * @return array  array of strings containing SQL
     */
    public function getTablesCreateSql();

    /**
     * Creates a new table in the database.
     *
     * @param string $nameWithoutPrefix   The name of the table without any prefix.
     * @param string $createDefinition    The table create definition
     */
    public function createTable($nameWithoutPrefix, $createDefinition);

    /**
     * Create database
     *
     * @param string $dbName Name of the database to create
     */
    public function createDatabase($dbName = null);

    /**
     * Drop database
     */
    public function dropDatabase();

    /**
     * Create all tables
     */
    public function createTables();

    /**
     * Creates an entry in the User table for the "anonymous" user.
     */
    public function createAnonymousUser();

    /**
     * Records the Matomo version a user used when installing this Matomo for the first time
     */
    public function recordInstallVersion();

    /**
     * Returns which Matomo version was used to install this Matomo for the first time.
     */
    public function getInstallVersion();

    /**
     * Returns the supported read isolation transaction level
     *
     * For example:
     *      READ COMMITTED
     *      or
     *      READ UNCOMMITTED
     */
    public function getSupportedReadIsolationTransactionLevel(): string;

    /**
     * Truncate all tables
     */
    public function truncateAllTables();

    /**
     * Names of all the prefixed tables in Matomo
     * Doesn't use the DB
     *
     * @return array  Table names
     */
    public function getTablesNames();

    /**
     * Get list of tables installed
     *
     * @param bool $forceReload Invalidate cache
     * @return array  installed Tables
     */
    public function getTablesInstalled($forceReload = true);

    /**
     * Get list of installed columns in a table
     *
     * @param  string $tableName The name of a table.
     *
     * @return array  Installed columns indexed by the column name.
     */
    public function getTableColumns($tableName);

    /**
     * Checks whether any table exists
     *
     * @return bool  True if tables exist; false otherwise
     */
    public function hasTables();

    /**
     * Adds a max execution time query hint into a SELECT query if $limit is bigger than 0
     * (floating values for limit might be rounded to full seconds depending on DB support)
     *
     * @param string $sql  query to add hint to
     * @param float $limit  time limit in seconds
     */
    public function addMaxExecutionTimeHintToQuery(string $sql, float $limit): string;

    /**
     * Returns if the database supports column updates in table updates.
     * Some database engines are performing sanity checks for table updates. Those might include checking if all columns used
     * already exist. In such a case queries like this might fail: `ALTER TABLE t ADD COLUMN b, ADD INDEX i (b)`
     *
     */
    public function supportsComplexColumnUpdates(): bool;

    /**
     * Returns the default collation for a charset used by this database engine.
     *
     *
     */
    public function getDefaultCollationForCharset(string $charset): string;

    /**
     * Return the default port used by this database engine
     *
     */
    public function getDefaultPort(): int;

    /**
     * Return the table options to use for a CREATE TABLE statement.
     *
     */
    public function getTableCreateOptions(): string;

    /**
     * Returns if performing on `OPTIMIZE TABLE` is supported for InnoDb tables
     *
     */
    public function isOptimizeInnoDBSupported(): bool;

    /**
     * Runs an `OPTIMIZE TABLE` query on the supplied table or tables.
     *
     * Tables will only be optimized if the `[General] enable_sql_optimize_queries` INI config option is
     * set to **1**.
     *
     * @param array $tables The name of the table to optimize or an array of tables to optimize.
     *                      Table names must be prefixed (see {@link Piwik\Common::prefixTable()}).
     * @param bool $force If true, the `OPTIMIZE TABLE` query will be run even if InnoDB tables are being used.
     */
    public function optimizeTables(array $tables, bool $force = false): bool;

    /**
     * Returns if the database engine can provide a rollup ranking query result
     * without needing additional sorting.
     *
     */
    public function supportsRankingRollupWithoutExtraSorting(): bool;

    /**
     * Returns if the database engine is able to use sorted subqueries
     *
     */
    public function supportsSortingInSubquery(): bool;

    /**
     * Returns the version of the database server
     */
    public function getVersion(): string;

    /**
     * Returns if the used database version has reached its EOL
     */
    public function hasReachedEOL(): bool;

    /**
     * Returns the minimum supported version set for the schema
     */
    public function getMinimumSupportedVersion(): string;
}