1<?php
2/**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9
10namespace Piwik\Db;
11
12/**
13 * Database schema interface
14 */
15interface SchemaInterface
16{
17    /**
18     * Get the SQL to create a specific Piwik table
19     *
20     * @param string $tableName
21     * @return string  SQL
22     */
23    public function getTableCreateSql($tableName);
24
25    /**
26     * Get the SQL to create Piwik tables
27     *
28     * @return array  array of strings containing SQL
29     */
30    public function getTablesCreateSql();
31
32    /**
33     * Creates a new table in the database.
34     *
35     * @param string $nameWithoutPrefix   The name of the table without any piwik prefix.
36     * @param string $createDefinition    The table create definition
37     */
38    public function createTable($nameWithoutPrefix, $createDefinition);
39
40    /**
41     * Create database
42     *
43     * @param string $dbName Name of the database to create
44     */
45    public function createDatabase($dbName = null);
46
47    /**
48     * Drop database
49     */
50    public function dropDatabase();
51
52    /**
53     * Create all tables
54     */
55    public function createTables();
56
57    /**
58     * Creates an entry in the User table for the "anonymous" user.
59     */
60    public function createAnonymousUser();
61
62    /**
63     * Records the Matomo version a user used when installing this Matomo for the first time
64     */
65    public function recordInstallVersion();
66
67    /**
68     * Returns which Matomo version was used to install this Matomo for the first time.
69     */
70    public function getInstallVersion();
71
72    /**
73     * Truncate all tables
74     */
75    public function truncateAllTables();
76
77    /**
78     * Names of all the prefixed tables in piwik
79     * Doesn't use the DB
80     *
81     * @return array  Table names
82     */
83    public function getTablesNames();
84
85    /**
86     * Get list of tables installed
87     *
88     * @param bool $forceReload Invalidate cache
89     * @return array  installed Tables
90     */
91    public function getTablesInstalled($forceReload = true);
92
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    /**
103     * Checks whether any table exists
104     *
105     * @return bool  True if tables exist; false otherwise
106     */
107    public function hasTables();
108}
109