Blueprint
Uses
Properties
$table string
The table the blueprint describes.
$prefix string
The prefix of the table.
$columns Illuminate\...\ColumnDefinition[]
The columns that should be added to the table.
$commands Illuminate\...\Fluent[]
The commands that should be run for the table.
$engine string
The storage engine that should be used for the table.
$charset string
The default character set that should be used for the table.
$collation string
The collation that should be used for the table.
$temporary bool
Whether to make the table temporary.
$after string
The column to add new columns after.
Methods
__construct ( $table , Closure $callback , $prefix ) : void
Create a new schema blueprint.
Parameters
- $table string
- $callback Closure |null
- $prefix string
build ( Connection $connection , Grammar $grammar ) : void
Execute the blueprint against the database.
Parameters
- $connection Connection
- $grammar Grammar
toSql ( Connection $connection , Grammar $grammar ) : array
Get the raw SQL statements for the blueprint.
Parameters
- $connection Connection
- $grammar Grammar
ensureCommandsAreValid ( Connection $connection ) : void
Ensure the commands on the blueprint are valid for the connection type.
Parameters
- $connection Connection
commandsNamed ( array $names ) : Collection
Get all of the commands matching the given names.
Parameters
- $names array
addImpliedCommands ( Grammar $grammar ) : void
Add the commands that are implied by the blueprint's state.
Parameters
- $grammar Grammar
addFluentIndexes ( ) : void
Add the index commands fluently specified on columns.
addFluentCommands ( Grammar $grammar ) : void
Add the fluent commands specified on any columns.
Parameters
- $grammar Grammar
creating ( ) : bool
Determine if the blueprint has a create command.
temporary ( ) : void
Indicate that the table needs to be temporary.
dropColumn ( $columns ) : Fluent
Indicate that the given columns should be dropped.
Parameters
- $columns array|mixed
renameColumn ( $from , $to ) : Fluent
Indicate that the given columns should be renamed.
Parameters
- $from string
- $to string
dropPrimary ( $index ) : Fluent
Indicate that the given primary key should be dropped.
Parameters
- $index string|array|null
dropUnique ( $index ) : Fluent
Indicate that the given unique key should be dropped.
Parameters
- $index string|array
dropIndex ( $index ) : Fluent
Indicate that the given index should be dropped.
Parameters
- $index string|array
dropFullText ( $index ) : Fluent
Indicate that the given fulltext index should be dropped.
Parameters
- $index string|array
dropSpatialIndex ( $index ) : Fluent
Indicate that the given spatial index should be dropped.
Parameters
- $index string|array
dropForeign ( $index ) : Fluent
Indicate that the given foreign key should be dropped.
Parameters
- $index string|array
dropConstrainedForeignId ( $column ) : Fluent
Indicate that the given column and foreign key should be dropped.
Parameters
- $column string
renameIndex ( $from , $to ) : Fluent
Indicate that the given indexes should be renamed.
Parameters
- $from string
- $to string
dropTimestamps ( ) : void
Indicate that the timestamp columns should be dropped.
dropTimestampsTz ( ) : void
Indicate that the timestamp columns should be dropped.
dropSoftDeletes ( $column ) : void
Indicate that the soft delete column should be dropped.
Parameters
- $column string
dropSoftDeletesTz ( $column ) : void
Indicate that the soft delete column should be dropped.
Parameters
- $column string
dropRememberToken ( ) : void
Indicate that the remember token column should be dropped.
dropMorphs ( $name , $indexName ) : void
Indicate that the polymorphic columns should be dropped.
Parameters
- $name string
- $indexName string|null
primary ( $columns , $name , $algorithm ) : Fluent
Specify the primary key(s) for the table.
Parameters
- $columns string|array
- $name string|null
- $algorithm string|null
unique ( $columns , $name , $algorithm ) : Fluent
Specify a unique index for the table.
Parameters
- $columns string|array
- $name string|null
- $algorithm string|null
index ( $columns , $name , $algorithm ) : Fluent
Specify an index for the table.
Parameters
- $columns string|array
- $name string|null
- $algorithm string|null
fullText ( $columns , $name , $algorithm ) : Fluent
Specify an fulltext for the table.
Parameters
- $columns string|array
- $name string|null
- $algorithm string|null
spatialIndex ( $columns , $name ) : Fluent
Specify a spatial index for the table.
Parameters
- $columns string|array
- $name string|null
rawIndex ( $expression , $name ) : Fluent
Specify a raw index for the table.
Parameters
- $expression string
- $name string
foreign ( $columns , $name ) : ForeignKeyDefinition
Specify a foreign key for the table.
Parameters
- $columns string|array
- $name string|null
id ( $column ) : ColumnDefinition
Create a new auto-incrementing big integer (8-byte) column on the table.
Parameters
- $column string
increments ( $column ) : ColumnDefinition
Create a new auto-incrementing integer (4-byte) column on the table.
Parameters
- $column string
integerIncrements ( $column ) : ColumnDefinition
Create a new auto-incrementing integer (4-byte) column on the table.
Parameters
- $column string
tinyIncrements ( $column ) : ColumnDefinition
Create a new auto-incrementing tiny integer (1-byte) column on the table.
Parameters
- $column string
smallIncrements ( $column ) : ColumnDefinition
Create a new auto-incrementing small integer (2-byte) column on the table.
Parameters
- $column string
mediumIncrements ( $column ) : ColumnDefinition
Create a new auto-incrementing medium integer (3-byte) column on the table.
Parameters
- $column string
bigIncrements ( $column ) : ColumnDefinition
Create a new auto-incrementing big integer (8-byte) column on the table.
Parameters
- $column string
char ( $column , $length ) : ColumnDefinition
Create a new char column on the table.
Parameters
- $column string
- $length int|null
string ( $column , $length ) : ColumnDefinition
Create a new string column on the table.
Parameters
- $column string
- $length int|null
tinyText ( $column ) : ColumnDefinition
Create a new tiny text column on the table.
Parameters
- $column string
text ( $column ) : ColumnDefinition
Create a new text column on the table.
Parameters
- $column string
mediumText ( $column ) : ColumnDefinition
Create a new medium text column on the table.
Parameters
- $column string
longText ( $column ) : ColumnDefinition
Create a new long text column on the table.
Parameters
- $column string
integer ( $column , $autoIncrement , $unsigned ) : ColumnDefinition
Create a new integer (4-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
- $unsigned bool
tinyInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition
Create a new tiny integer (1-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
- $unsigned bool
smallInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition
Create a new small integer (2-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
- $unsigned bool
mediumInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition
Create a new medium integer (3-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
- $unsigned bool
bigInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition
Create a new big integer (8-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
- $unsigned bool
unsignedInteger ( $column , $autoIncrement ) : ColumnDefinition
Create a new unsigned integer (4-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
unsignedTinyInteger ( $column , $autoIncrement ) : ColumnDefinition
Create a new unsigned tiny integer (1-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
unsignedSmallInteger ( $column , $autoIncrement ) : ColumnDefinition
Create a new unsigned small integer (2-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
unsignedMediumInteger ( $column , $autoIncrement ) : ColumnDefinition
Create a new unsigned medium integer (3-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
unsignedBigInteger ( $column , $autoIncrement ) : ColumnDefinition
Create a new unsigned big integer (8-byte) column on the table.
Parameters
- $column string
- $autoIncrement bool
foreignId ( $column ) : ForeignIdColumnDefinition
Create a new unsigned big integer (8-byte) column on the table.
Parameters
- $column string
foreignIdFor ( $model , $column ) : ForeignIdColumnDefinition
Create a foreign ID column for the given model.
Parameters
- $model Model |string
- $column string|null
float ( $column , $total , $places , $unsigned ) : ColumnDefinition
Create a new float column on the table.
Parameters
- $column string
- $total int
- $places int
- $unsigned bool
double ( $column , $total , $places , $unsigned ) : ColumnDefinition
Create a new double column on the table.
Parameters
- $column string
- $total int|null
- $places int|null
- $unsigned bool
decimal ( $column , $total , $places , $unsigned ) : ColumnDefinition
Create a new decimal column on the table.
Parameters
- $column string
- $total int
- $places int
- $unsigned bool
unsignedFloat ( $column , $total , $places ) : ColumnDefinition
Create a new unsigned float column on the table.
Parameters
- $column string
- $total int
- $places int
unsignedDouble ( $column , $total , $places ) : ColumnDefinition
Create a new unsigned double column on the table.
Parameters
- $column string
- $total int
- $places int
unsignedDecimal ( $column , $total , $places ) : ColumnDefinition
Create a new unsigned decimal column on the table.
Parameters
- $column string
- $total int
- $places int
boolean ( $column ) : ColumnDefinition
Create a new boolean column on the table.
Parameters
- $column string
enum ( $column , array $allowed ) : ColumnDefinition
Create a new enum column on the table.
Parameters
- $column string
- $allowed array
set ( $column , array $allowed ) : ColumnDefinition
Create a new set column on the table.
Parameters
- $column string
- $allowed array
json ( $column ) : ColumnDefinition
Create a new json column on the table.
Parameters
- $column string
jsonb ( $column ) : ColumnDefinition
Create a new jsonb column on the table.
Parameters
- $column string
date ( $column ) : ColumnDefinition
Create a new date column on the table.
Parameters
- $column string
dateTime ( $column , $precision ) : ColumnDefinition
Create a new date-time column on the table.
Parameters
- $column string
- $precision int
dateTimeTz ( $column , $precision ) : ColumnDefinition
Create a new date-time column (with time zone) on the table.
Parameters
- $column string
- $precision int
time ( $column , $precision ) : ColumnDefinition
Create a new time column on the table.
Parameters
- $column string
- $precision int
timeTz ( $column , $precision ) : ColumnDefinition
Create a new time column (with time zone) on the table.
Parameters
- $column string
- $precision int
timestamp ( $column , $precision ) : ColumnDefinition
Create a new timestamp column on the table.
Parameters
- $column string
- $precision int
timestampTz ( $column , $precision ) : ColumnDefinition
Create a new timestamp (with time zone) column on the table.
Parameters
- $column string
- $precision int
timestamps ( $precision ) : void
Add nullable creation and update timestamps to the table.
Parameters
- $precision int
nullableTimestamps ( $precision ) : void
Add nullable creation and update timestamps to the table.
Parameters
- $precision int
timestampsTz ( $precision ) : void
Add creation and update timestampTz columns to the table.
Parameters
- $precision int
softDeletes ( $column , $precision ) : ColumnDefinition
Add a "deleted at" timestamp for the table.
Parameters
- $column string
- $precision int
softDeletesTz ( $column , $precision ) : ColumnDefinition
Add a "deleted at" timestampTz for the table.
Parameters
- $column string
- $precision int
year ( $column ) : ColumnDefinition
Create a new year column on the table.
Parameters
- $column string
binary ( $column ) : ColumnDefinition
Create a new binary column on the table.
Parameters
- $column string
uuid ( $column ) : ColumnDefinition
Create a new uuid column on the table.
Parameters
- $column string
foreignUuid ( $column ) : ForeignIdColumnDefinition
Create a new UUID column on the table with a foreign key constraint.
Parameters
- $column string
ipAddress ( $column ) : ColumnDefinition
Create a new IP address column on the table.
Parameters
- $column string
macAddress ( $column ) : ColumnDefinition
Create a new MAC address column on the table.
Parameters
- $column string
geometry ( $column ) : ColumnDefinition
Create a new geometry column on the table.
Parameters
- $column string
point ( $column , $srid ) : ColumnDefinition
Create a new point column on the table.
Parameters
- $column string
- $srid int|null
lineString ( $column ) : ColumnDefinition
Create a new linestring column on the table.
Parameters
- $column string
polygon ( $column ) : ColumnDefinition
Create a new polygon column on the table.
Parameters
- $column string
geometryCollection ( $column ) : ColumnDefinition
Create a new geometrycollection column on the table.
Parameters
- $column string
multiPoint ( $column ) : ColumnDefinition
Create a new multipoint column on the table.
Parameters
- $column string
multiLineString ( $column ) : ColumnDefinition
Create a new multilinestring column on the table.
Parameters
- $column string
multiPolygon ( $column ) : ColumnDefinition
Create a new multipolygon column on the table.
Parameters
- $column string
multiPolygonZ ( $column ) : ColumnDefinition
Create a new multipolygon column on the table.
Parameters
- $column string
computed ( $column , $expression ) : ColumnDefinition
Create a new generated, computed column on the table.
Parameters
- $column string
- $expression string
morphs ( $name , $indexName ) : void
Add the proper columns for a polymorphic table.
Parameters
- $name string
- $indexName string|null
nullableMorphs ( $name , $indexName ) : void
Add nullable columns for a polymorphic table.
Parameters
- $name string
- $indexName string|null
numericMorphs ( $name , $indexName ) : void
Add the proper columns for a polymorphic table using numeric IDs (incremental).
Parameters
- $name string
- $indexName string|null
nullableNumericMorphs ( $name , $indexName ) : void
Add nullable columns for a polymorphic table using numeric IDs (incremental).
Parameters
- $name string
- $indexName string|null
uuidMorphs ( $name , $indexName ) : void
Add the proper columns for a polymorphic table using UUIDs.
Parameters
- $name string
- $indexName string|null
nullableUuidMorphs ( $name , $indexName ) : void
Add nullable columns for a polymorphic table using UUIDs.
Parameters
- $name string
- $indexName string|null
indexCommand ( $type , $columns , $index , $algorithm ) : Fluent
Add a new index command to the blueprint.
Parameters
- $type string
- $columns string|array
- $index string
- $algorithm string|null
dropIndexCommand ( $command , $type , $index ) : Fluent
Create a new drop index command on the blueprint.
Parameters
- $command string
- $type string
- $index string|array
createIndexName ( $type , array $columns ) : string
Create a default index name for the table.
Parameters
- $type string
- $columns array
addColumn ( $type , $name , array $parameters ) : ColumnDefinition
Add a new column to the blueprint.
Parameters
- $type string
- $name string
- $parameters array
addColumnDefinition ( $definition ) : ColumnDefinition
Add a new column definition to the blueprint.
Parameters
- $definition ColumnDefinition
after ( $column , Closure $callback ) : void
Add the columns from the callback after the given column.
Parameters
- $column string
- $callback Closure
removeColumn ( $name ) : $this
Remove a column from the schema blueprint.
Parameters
- $name string
addCommand ( $name , array $parameters ) : Fluent
Add a new command to the blueprint.
Parameters
- $name string
- $parameters array
createCommand ( $name , array $parameters ) : Fluent
Create a new Fluent command.
Parameters
- $name string
- $parameters array
getTable ( ) : string
Get the table the blueprint describes.
getColumns ( ) : Illuminate\...\ColumnDefinition[]
Get the columns on the blueprint.
getCommands ( ) : Illuminate\...\Fluent[]
Get the commands on the blueprint.
getAddedColumns ( ) : Illuminate\...\ColumnDefinition[]
Get the columns on the blueprint that should be added.
getChangedColumns ( ) : Illuminate\...\ColumnDefinition[]
Get the columns on the blueprint that should be changed.
hasAutoIncrementColumn ( ) : bool
Determine if the blueprint has auto-increment columns.
autoIncrementingStartingValues ( ) : array
Get the auto-increment column starting values.