final class MysqlSchemaGrammar implements SchemaGrammarInterface (View source)

Compiles framework schema definitions to MySQL and MariaDB DDL with configured table prefixes.

Constants

private UNSIGNED_TYPES

Methods

Creates a grammar with the configured table prefix and SQL value escaper.

string
compileCreateDatabase(string $database)

Compiles MySQL database creation with a validated database identifier.

string
string
compileDropDatabase(string $database)

Compiles MySQL database removal with a validated database identifier.

string
string

Compiles the primary CREATE TABLE statement for one immutable table definition.

string
array

Compiles every statement required to create a table and its deferred constraints.

array
array

Compiles ordered MySQL ALTER TABLE statements for all operations in a blueprint definition.

array
string
compileDropTable(string $table, bool $ifExists = false)

Compiles a DROP TABLE statement with optional MySQL existence protection.

string
string
compileRenameTable(string $from, string $to)

Compiles a MySQL table rename while applying configured prefixes to both names.

string
string
compileAddColumn(string $table, ColumnDefinition $column)

Compiles a MySQL ALTER TABLE clause that adds a column.

string
string
compileModifyColumn(string $table, ColumnDefinition $column)

Compiles a MySQL ALTER TABLE clause that modifies or renames a column.

string
string
compileDropColumn(string $table, string $column)

Compiles a MySQL ALTER TABLE clause that drops a column.

string
string
compileAddIndex(string $table, IndexDefinition $index)

Compiles a MySQL ALTER TABLE clause that adds an index.

string
string
compileDropIndex(string $table, string $index)

Compiles a MySQL ALTER TABLE clause that drops an index.

string
string
compileAddForeignKey(string $table, ForeignKeyDefinition $foreignKey)

Compiles a MySQL ALTER TABLE clause that adds a foreign-key constraint.

string
string
compileDropForeignKey(string $table, string $foreignKey)

Compiles a MySQL ALTER TABLE clause that drops a foreign-key constraint.

string

Details

__construct

__construct(MysqlSqlEscaper $escaper, DatabaseConfig $config)

Creates a grammar with the configured table prefix and SQL value escaper.

Parameters

MysqlSqlEscaper $escaper
DatabaseConfig $config

compileCreateDatabase

string compileCreateDatabase(string $database)

Compiles MySQL database creation with a validated database identifier.

Parameters

string $database

Return Value

string

compileDropDatabase

string compileDropDatabase(string $database)

Compiles MySQL database removal with a validated database identifier.

Parameters

string $database

Return Value

string

compileCreateTable

string compileCreateTable(TableDefinition $table)

Compiles the primary CREATE TABLE statement for one immutable table definition.

Parameters

TableDefinition $table

Return Value

string

compileCreateTableStatements

array compileCreateTableStatements(TableDefinition $table)

Compiles every statement required to create a table and its deferred constraints.

Parameters

TableDefinition $table

Return Value

array

compileAlterTable

array compileAlterTable(TableDefinition $table)

Compiles ordered MySQL ALTER TABLE statements for all operations in a blueprint definition.

Parameters

TableDefinition $table

Return Value

array

compileDropTable

string compileDropTable(string $table, bool $ifExists = false)

Compiles a DROP TABLE statement with optional MySQL existence protection.

Parameters

string $table
bool $ifExists

Return Value

string

compileRenameTable

string compileRenameTable(string $from, string $to)

Compiles a MySQL table rename while applying configured prefixes to both names.

Parameters

string $from
string $to

Return Value

string

compileAddColumn

string compileAddColumn(string $table, ColumnDefinition $column)

Compiles a MySQL ALTER TABLE clause that adds a column.

Parameters

string $table
ColumnDefinition $column

Return Value

string

compileModifyColumn

string compileModifyColumn(string $table, ColumnDefinition $column)

Compiles a MySQL ALTER TABLE clause that modifies or renames a column.

Parameters

string $table
ColumnDefinition $column

Return Value

string

compileDropColumn

string compileDropColumn(string $table, string $column)

Compiles a MySQL ALTER TABLE clause that drops a column.

Parameters

string $table
string $column

Return Value

string

compileAddIndex

string compileAddIndex(string $table, IndexDefinition $index)

Compiles a MySQL ALTER TABLE clause that adds an index.

Parameters

string $table
IndexDefinition $index

Return Value

string

compileDropIndex

string compileDropIndex(string $table, string $index)

Compiles a MySQL ALTER TABLE clause that drops an index.

Parameters

string $table
string $index

Return Value

string

compileAddForeignKey

string compileAddForeignKey(string $table, ForeignKeyDefinition $foreignKey)

Compiles a MySQL ALTER TABLE clause that adds a foreign-key constraint.

Parameters

string $table
ForeignKeyDefinition $foreignKey

Return Value

string

compileDropForeignKey

string compileDropForeignKey(string $table, string $foreignKey)

Compiles a MySQL ALTER TABLE clause that drops a foreign-key constraint.

Parameters

string $table
string $foreignKey

Return Value

string