Adapter
1 month ago
Schema
2 weeks ago
Adapter.php
1 month ago
AdapterInterface.php
1 month ago
BatchInsert.php
6 months ago
Schema.php
1 month ago
SchemaInterface.php
1 month ago
Settings.php
1 year ago
TransactionLevel.php
1 year ago
TransactionalDatabaseDynamicTrait.php
1 year ago
TransactionalDatabaseInterface.php
1 year ago
TransactionalDatabaseStaticTrait.php
1 year ago
SchemaInterface.php
170 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Db; |
| 10 | |
| 11 | /** |
| 12 | * Database schema interface |
| 13 | */ |
| 14 | interface SchemaInterface |
| 15 | { |
| 16 | /** |
| 17 | * Returns the type of the current database (e.g. MySQL, MariaDB, ...) |
| 18 | */ |
| 19 | public function getDatabaseType() : string; |
| 20 | /** |
| 21 | * Get the SQL to create a specific Matomo table |
| 22 | * |
| 23 | * @param string $tableName |
| 24 | * @return string SQL |
| 25 | */ |
| 26 | public function getTableCreateSql($tableName); |
| 27 | /** |
| 28 | * Get the SQL to create Matomo tables |
| 29 | * |
| 30 | * @return array array of strings containing SQL |
| 31 | */ |
| 32 | public function getTablesCreateSql(); |
| 33 | /** |
| 34 | * Creates a new table in the database. |
| 35 | * |
| 36 | * @param string $nameWithoutPrefix The name of the table without any prefix. |
| 37 | * @param string $createDefinition The table create definition |
| 38 | */ |
| 39 | public function createTable($nameWithoutPrefix, $createDefinition); |
| 40 | /** |
| 41 | * Create database |
| 42 | * |
| 43 | * @param string $dbName Name of the database to create |
| 44 | */ |
| 45 | public function createDatabase($dbName = null); |
| 46 | /** |
| 47 | * Drop database |
| 48 | */ |
| 49 | public function dropDatabase(); |
| 50 | /** |
| 51 | * Create all tables |
| 52 | */ |
| 53 | public function createTables(); |
| 54 | /** |
| 55 | * Creates an entry in the User table for the "anonymous" user. |
| 56 | */ |
| 57 | public function createAnonymousUser(); |
| 58 | /** |
| 59 | * Records the Matomo version a user used when installing this Matomo for the first time |
| 60 | */ |
| 61 | public function recordInstallVersion(); |
| 62 | /** |
| 63 | * Returns which Matomo version was used to install this Matomo for the first time. |
| 64 | */ |
| 65 | public function getInstallVersion(); |
| 66 | /** |
| 67 | * Returns the supported read isolation transaction level |
| 68 | * |
| 69 | * For example: |
| 70 | * READ COMMITTED |
| 71 | * or |
| 72 | * READ UNCOMMITTED |
| 73 | */ |
| 74 | public function getSupportedReadIsolationTransactionLevel() : string; |
| 75 | /** |
| 76 | * Truncate all tables |
| 77 | */ |
| 78 | public function truncateAllTables(); |
| 79 | /** |
| 80 | * Names of all the prefixed tables in Matomo |
| 81 | * Doesn't use the DB |
| 82 | * |
| 83 | * @return array Table names |
| 84 | */ |
| 85 | public function getTablesNames(); |
| 86 | /** |
| 87 | * Get list of tables installed |
| 88 | * |
| 89 | * @param bool $forceReload Invalidate cache |
| 90 | * @return array installed Tables |
| 91 | */ |
| 92 | public function getTablesInstalled($forceReload = \true); |
| 93 | /** |
| 94 | * Get list of installed columns in a table |
| 95 | * |
| 96 | * @param string $tableName The name of a table. |
| 97 | * |
| 98 | * @return array Installed columns indexed by the column name. |
| 99 | */ |
| 100 | public function getTableColumns($tableName); |
| 101 | /** |
| 102 | * Checks whether any table exists |
| 103 | * |
| 104 | * @return bool True if tables exist; false otherwise |
| 105 | */ |
| 106 | public function hasTables(); |
| 107 | /** |
| 108 | * Adds a max execution time query hint into a SELECT query if $limit is bigger than 0 |
| 109 | * (floating values for limit might be rounded to full seconds depending on DB support) |
| 110 | * |
| 111 | * @param string $sql query to add hint to |
| 112 | * @param float $limit time limit in seconds |
| 113 | */ |
| 114 | public function addMaxExecutionTimeHintToQuery(string $sql, float $limit) : string; |
| 115 | /** |
| 116 | * Returns if the database supports column updates in table updates. |
| 117 | * Some database engines are performing sanity checks for table updates. Those might include checking if all columns used |
| 118 | * already exist. In such a case queries like this might fail: `ALTER TABLE t ADD COLUMN b, ADD INDEX i (b)` |
| 119 | */ |
| 120 | public function supportsComplexColumnUpdates() : bool; |
| 121 | /** |
| 122 | * Returns the default collation for a charset used by this database engine. |
| 123 | */ |
| 124 | public function getDefaultCollationForCharset(string $charset) : string; |
| 125 | /** |
| 126 | * Return the default port used by this database engine |
| 127 | */ |
| 128 | public function getDefaultPort() : int; |
| 129 | /** |
| 130 | * Return the table options to use for a CREATE TABLE statement. |
| 131 | */ |
| 132 | public function getTableCreateOptions() : string; |
| 133 | /** |
| 134 | * Returns if performing on `OPTIMIZE TABLE` is supported for InnoDb tables |
| 135 | */ |
| 136 | public function isOptimizeInnoDBSupported() : bool; |
| 137 | /** |
| 138 | * Runs an `OPTIMIZE TABLE` query on the supplied table or tables. |
| 139 | * |
| 140 | * Tables will only be optimized if the `[General] enable_sql_optimize_queries` INI config option is |
| 141 | * set to **1**. |
| 142 | * |
| 143 | * @param array $tables The name of the table to optimize or an array of tables to optimize. |
| 144 | * Table names must be prefixed (see {@link Piwik\Common::prefixTable()}). |
| 145 | * @param bool $force If true, the `OPTIMIZE TABLE` query will be run even if InnoDB tables are being used. |
| 146 | */ |
| 147 | public function optimizeTables(array $tables, bool $force = \false) : bool; |
| 148 | /** |
| 149 | * Returns if the database engine can provide a rollup ranking query result |
| 150 | * without needing additional sorting. |
| 151 | */ |
| 152 | public function supportsRankingRollupWithoutExtraSorting() : bool; |
| 153 | /** |
| 154 | * Returns if the database engine is able to use sorted subqueries |
| 155 | */ |
| 156 | public function supportsSortingInSubquery() : bool; |
| 157 | /** |
| 158 | * Returns the version of the database server |
| 159 | */ |
| 160 | public function getVersion() : string; |
| 161 | /** |
| 162 | * Returns if the used database version has reached its EOL |
| 163 | */ |
| 164 | public function hasReachedEOL() : bool; |
| 165 | /** |
| 166 | * Returns the minimum supported version set for the schema |
| 167 | */ |
| 168 | public function getMinimumSupportedVersion() : string; |
| 169 | } |
| 170 |