final class SchemaCompiler (View source)

Turns schema blueprints and immutable table definitions into driver-specific SQL statements.

Methods

Creates a compiler that delegates dialect-specific SQL to the selected grammar.

string
compileCreate(string $table, Closure $definition, bool $ifNotExists = false)

Compiles the primary create-table statement for consumers that expect one SQL string.

string
array
compileCreateStatements(string $table, Closure $definition, bool $ifNotExists = false)

Materializes a blueprint once and returns all statements required by the grammar.

array
string

Compiles the primary SQL statement for an immutable table definition.

string
array

Compiles all statements for an immutable table definition, including driver-specific indexes or constraints.

array
array
compileTable(string $table, Closure $definition)

Materializes an alteration blueprint and compiles its statements without executing them.

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

Compiles a drop-table operation with optional existence protection.

string
string
compileRename(string $from, string $to)

Compiles a table rename operation.

string
string
compileCreateDatabase(string $database)

Compiles creation of a database namespace.

string
string
compileDropDatabase(string $database)

Compiles removal of a database namespace.

string

Details

__construct

__construct(SchemaGrammarInterface $grammar)

Creates a compiler that delegates dialect-specific SQL to the selected grammar.

Parameters

SchemaGrammarInterface $grammar

compileCreate

string compileCreate(string $table, Closure $definition, bool $ifNotExists = false)

Compiles the primary create-table statement for consumers that expect one SQL string.

Parameters

string $table
Closure $definition
bool $ifNotExists

Return Value

string

compileCreateStatements

array compileCreateStatements(string $table, Closure $definition, bool $ifNotExists = false)

Materializes a blueprint once and returns all statements required by the grammar.

Parameters

string $table
Closure $definition
bool $ifNotExists

Return Value

array

compileCreateTable

string compileCreateTable(TableDefinition $definition)

Compiles the primary SQL statement for an immutable table definition.

Parameters

TableDefinition $definition

Return Value

string

compileCreateTableStatements

array compileCreateTableStatements(TableDefinition $definition)

Compiles all statements for an immutable table definition, including driver-specific indexes or constraints.

Parameters

TableDefinition $definition

Return Value

array

compileTable

array compileTable(string $table, Closure $definition)

Materializes an alteration blueprint and compiles its statements without executing them.

Parameters

string $table
Closure $definition

Return Value

array

compileDrop

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

Compiles a drop-table operation with optional existence protection.

Parameters

string $table
bool $ifExists

Return Value

string

compileRename

string compileRename(string $from, string $to)

Compiles a table rename operation.

Parameters

string $from
string $to

Return Value

string

compileCreateDatabase

string compileCreateDatabase(string $database)

Compiles creation of a database namespace.

Parameters

string $database

Return Value

string

compileDropDatabase

string compileDropDatabase(string $database)

Compiles removal of a database namespace.

Parameters

string $database

Return Value

string