-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathSQLDialectInterface.php
More file actions
74 lines (63 loc) · 2.58 KB
/
SQLDialectInterface.php
File metadata and controls
74 lines (63 loc) · 2.58 KB
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
<?php namespace DBDiff\SQLGen\Dialect;
interface SQLDialectInterface {
/** Quote a single identifier (table, column, index name). */
public function quote(string $name): string;
/** The PDO driver string: mysql | pgsql | sqlite */
public function getDriver(): string;
/**
* Whether this dialect is MySQL-only.
* When true, MySQL-specific diff objects (Engine, Charset, Collation)
* will be handled; when false those DiffToSQL classes return empty strings.
*/
public function isMySQLOnly(): bool;
/**
* DROP INDEX statement.
* MySQL: ALTER TABLE `t` DROP INDEX `key`
* Postgres/SQLite: DROP INDEX "key"
*/
public function dropIndex(string $table, string $key): string;
/**
* DROP TRIGGER statement.
* MySQL: DROP TRIGGER IF EXISTS `trigger`
* Postgres: DROP TRIGGER IF EXISTS "trigger" ON "table"
* SQLite: DROP TRIGGER IF EXISTS "trigger"
*/
public function dropTrigger(string $trigger, string $table): string;
/**
* ADD COLUMN statement.
* $colDef is the full column DDL fragment (already quoted), e.g.
* MySQL: `col` varchar(255) NOT NULL
* Postgres/SQLite: "col" varchar(255) NOT NULL
*
* MySQL omits the COLUMN keyword for backwards-compat with existing baselines.
* Postgres and SQLite always include COLUMN.
*/
public function addColumn(string $table, string $colDef): string;
/**
* DROP COLUMN statement.
* $col is the bare (unquoted) column name.
*
* MySQL omits the COLUMN keyword for backwards-compat with existing baselines.
* Postgres and SQLite always include COLUMN.
*/
public function dropColumn(string $table, string $col): string;
/**
* ALTER COLUMN / CHANGE COLUMN.
* $col is the bare column name.
* $newDef is the full column DDL fragment produced by the adapter,
* e.g. `col` varchar(255) NOT NULL (MySQL)
* or "col" varchar(255) NOT NULL (Postgres/SQLite)
*
* Returns the complete statement(s) including trailing semicolons.
*/
public function changeColumn(string $table, string $col, string $newDef): string;
/**
* DROP CONSTRAINT statement.
* $schema is the full constraint DDL used to detect the constraint type.
*
* MySQL requires DROP FOREIGN KEY for FK constraints; DROP CONSTRAINT
* only works for CHECK constraints. Postgres and SQLite use the
* standard DROP CONSTRAINT for all types.
*/
public function dropConstraint(string $table, string $name, string $schema): string;
}