final class Schema (View source)

Compiles and executes schema changes through the active driver's grammar and query interface.

Methods

Creates a schema executor bound to the configured grammar and database driver.

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

Defines and executes a new table, optionally tolerating a pre-existing table.

bool
bool

Executes a previously materialized table definition without invoking a blueprint callback.

bool
bool
table(string $table, Closure $definition)

Defines and executes alterations for an existing table in grammar-defined statement order.

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

Drops a table, optionally allowing an absent table without treating it as a failure.

bool
bool
rename(string $from, string $to)

Renames one table through the active grammar's identifier rules.

bool
bool
createDatabase(string $database)

Creates a database through the active driver's schema grammar.

bool
bool
dropDatabase(string $database)

Drops a database through the active driver's schema grammar.

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

Compiles the first create-table statement for callers that require SQL without execution.

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

Compiles every statement required to create a table, including grammar-specific auxiliary statements.

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

Compiles every statement required to alter an existing table without executing them.

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

Compiles a drop-table statement using the active grammar.

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

Compiles a table rename statement using the active grammar.

string

Details

__construct

__construct(SchemaCompiler $compiler, DatabaseDriverInterface $db)

Creates a schema executor bound to the configured grammar and database driver.

Parameters

SchemaCompiler $compiler
DatabaseDriverInterface $db

create

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

Defines and executes a new table, optionally tolerating a pre-existing table.

Parameters

string $table
Closure $definition
bool $ifNotExists

Return Value

bool

createTable

bool createTable(TableDefinition $definition)

Executes a previously materialized table definition without invoking a blueprint callback.

Parameters

TableDefinition $definition

Return Value

bool

table

bool table(string $table, Closure $definition)

Defines and executes alterations for an existing table in grammar-defined statement order.

Parameters

string $table
Closure $definition

Return Value

bool

drop

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

Drops a table, optionally allowing an absent table without treating it as a failure.

Parameters

string $table
bool $ifExists

Return Value

bool

rename

bool rename(string $from, string $to)

Renames one table through the active grammar's identifier rules.

Parameters

string $from
string $to

Return Value

bool

createDatabase

bool createDatabase(string $database)

Creates a database through the active driver's schema grammar.

Parameters

string $database

Return Value

bool

dropDatabase

bool dropDatabase(string $database)

Drops a database through the active driver's schema grammar.

Parameters

string $database

Return Value

bool

compileCreate

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

Compiles the first create-table statement for callers that require SQL without execution.

Parameters

string $table
Closure $definition
bool $ifNotExists

Return Value

string

compileCreateStatements

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

Compiles every statement required to create a table, including grammar-specific auxiliary statements.

Parameters

string $table
Closure $definition
bool $ifNotExists

Return Value

array

compileTable

array compileTable(string $table, Closure $definition)

Compiles every statement required to alter an existing table without executing them.

Parameters

string $table
Closure $definition

Return Value

array

compileDrop

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

Compiles a drop-table statement using the active grammar.

Parameters

string $table
bool $ifExists

Return Value

string

compileRename

string compileRename(string $from, string $to)

Compiles a table rename statement using the active grammar.

Parameters

string $from
string $to

Return Value

string