class Blueprint (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected $connection

The database connection instance.

protected $grammar

The schema grammar instance.

protected string $table

The table the blueprint describes.

protected string $prefix

The prefix of the table.

protected ColumnDefinition[] $columns

The columns that should be added to the table.

protected Fluent[] $commands

The commands that should be run for the table.

string $engine

The storage engine that should be used for the table.

string $charset

The default character set that should be used for the table.

string $collation

The collation that should be used for the table.

bool $temporary

Whether to make the table temporary.

string $after

The column to add new columns after.

protected BlueprintState|null $state

The blueprint state instance.

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

void
__construct(Connection $connection, string $table, Closure|null $callback = null, string $prefix = '')

Create a new schema blueprint.

void
build()

Execute the blueprint against the database.

array
toSql()

Get the raw SQL statements for the blueprint.

void
ensureCommandsAreValid()

Ensure the commands on the blueprint are valid for the connection type.

commandsNamed(array $names) deprecated

Get all of the commands matching the given names.

void
addImpliedCommands()

Add the commands that are implied by the blueprint's state.

void
addFluentIndexes()

Add the index commands fluently specified on columns.

void
addFluentCommands()

Add the fluent commands specified on any columns.

void
addAlterCommands()

Add the alter commands if whenever needed.

bool
creating()

Determine if the blueprint has a create command.

create()

Indicate that the table needs to be created.

void
engine(string $engine)

Specify the storage engine that should be used for the table.

void
innoDb()

Specify that the InnoDB storage engine should be used for the table (MySQL only).

void
charset(string $charset)

Specify the character set that should be used for the table.

void
collation(string $collation)

Specify the collation that should be used for the table.

void
temporary()

Indicate that the table needs to be temporary.

drop()

Indicate that the table should be dropped.

dropIfExists()

Indicate that the table should be dropped if it exists.

dropColumn(array|mixed $columns)

Indicate that the given columns should be dropped.

renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

dropPrimary(string|array|null $index = null)

Indicate that the given primary key should be dropped.

dropUnique(string|array $index)

Indicate that the given unique key should be dropped.

dropIndex(string|array $index)

Indicate that the given index should be dropped.

dropFullText(string|array $index)

Indicate that the given fulltext index should be dropped.

dropSpatialIndex(string|array $index)

Indicate that the given spatial index should be dropped.

dropForeign(string|array $index)

Indicate that the given foreign key should be dropped.

dropConstrainedForeignId(string $column)

Indicate that the given column and foreign key should be dropped.

dropForeignIdFor(Model|string $model, string|null $column = null)

Indicate that the given foreign key should be dropped.

dropConstrainedForeignIdFor(Model|string $model, string|null $column = null)

Indicate that the given foreign key should be dropped.

renameIndex(string $from, string $to)

Indicate that the given indexes should be renamed.

void
dropTimestamps()

Indicate that the timestamp columns should be dropped.

void
dropTimestampsTz()

Indicate that the timestamp columns should be dropped.

void
dropSoftDeletes(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

void
dropSoftDeletesTz(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

void
dropRememberToken()

Indicate that the remember token column should be dropped.

void
dropMorphs(string $name, string|null $indexName = null)

Indicate that the polymorphic columns should be dropped.

rename(string $to)

Rename the table to a given name.

primary(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify the primary key(s) for the table.

unique(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify a unique index for the table.

index(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify an index for the table.

fullText(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify an fulltext for the table.

spatialIndex(string|array $columns, string|null $name = null)

Specify a spatial index for the table.

rawIndex(string $expression, string $name)

Specify a raw index for the table.

foreign(string|array $columns, string|null $name = null)

Specify a foreign key for the table.

id(string $column = 'id')

Create a new auto-incrementing big integer (8-byte) column on the table.

increments(string $column)

Create a new auto-incrementing integer (4-byte) column on the table.

integerIncrements(string $column)

Create a new auto-incrementing integer (4-byte) column on the table.

tinyIncrements(string $column)

Create a new auto-incrementing tiny integer (1-byte) column on the table.

smallIncrements(string $column)

Create a new auto-incrementing small integer (2-byte) column on the table.

mediumIncrements(string $column)

Create a new auto-incrementing medium integer (3-byte) column on the table.

bigIncrements(string $column)

Create a new auto-incrementing big integer (8-byte) column on the table.

char(string $column, int|null $length = null)

Create a new char column on the table.

string(string $column, int|null $length = null)

Create a new string column on the table.

tinyText(string $column)

Create a new tiny text column on the table.

text(string $column)

Create a new text column on the table.

mediumText(string $column)

Create a new medium text column on the table.

longText(string $column)

Create a new long text column on the table.

integer(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new integer (4-byte) column on the table.

tinyInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new tiny integer (1-byte) column on the table.

smallInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new small integer (2-byte) column on the table.

mediumInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new medium integer (3-byte) column on the table.

bigInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new big integer (8-byte) column on the table.

unsignedInteger(string $column, bool $autoIncrement = false)

Create a new unsigned integer (4-byte) column on the table.

unsignedTinyInteger(string $column, bool $autoIncrement = false)

Create a new unsigned tiny integer (1-byte) column on the table.

unsignedSmallInteger(string $column, bool $autoIncrement = false)

Create a new unsigned small integer (2-byte) column on the table.

unsignedMediumInteger(string $column, bool $autoIncrement = false)

Create a new unsigned medium integer (3-byte) column on the table.

unsignedBigInteger(string $column, bool $autoIncrement = false)

Create a new unsigned big integer (8-byte) column on the table.

foreignId(string $column)

Create a new unsigned big integer (8-byte) column on the table.

foreignIdFor(Model|string $model, string|null $column = null)

Create a foreign ID column for the given model.

float(string $column, int $precision = 53)

Create a new float column on the table.

double(string $column)

Create a new double column on the table.

decimal(string $column, int $total = 8, int $places = 2)

Create a new decimal column on the table.

boolean(string $column)

Create a new boolean column on the table.

enum(string $column, array $allowed)

Create a new enum column on the table.

set(string $column, array $allowed)

Create a new set column on the table.

json(string $column)

Create a new json column on the table.

jsonb(string $column)

Create a new jsonb column on the table.

date(string $column)

Create a new date column on the table.

dateTime(string $column, int|null $precision = null)

Create a new date-time column on the table.

dateTimeTz(string $column, int|null $precision = null)

Create a new date-time column (with time zone) on the table.

time(string $column, int|null $precision = null)

Create a new time column on the table.

timeTz(string $column, int|null $precision = null)

Create a new time column (with time zone) on the table.

timestamp(string $column, int|null $precision = null)

Create a new timestamp column on the table.

timestampTz(string $column, int|null $precision = null)

Create a new timestamp (with time zone) column on the table.

void
timestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

void
nullableTimestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

void
timestampsTz(int|null $precision = null)

Add creation and update timestampTz columns to the table.

void
datetimes(int|null $precision = null)

Add creation and update datetime columns to the table.

softDeletes(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" timestamp for the table.

softDeletesTz(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" timestampTz for the table.

softDeletesDatetime(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" datetime column to the table.

year(string $column)

Create a new year column on the table.

binary(string $column, int|null $length = null, bool $fixed = false)

Create a new binary column on the table.

uuid(string $column = 'uuid')

Create a new UUID column on the table.

foreignUuid(string $column)

Create a new UUID column on the table with a foreign key constraint.

ulid(string $column = 'ulid', int|null $length = 26)

Create a new ULID column on the table.

foreignUlid(string $column, int|null $length = 26)

Create a new ULID column on the table with a foreign key constraint.

ipAddress(string $column = 'ip_address')

Create a new IP address column on the table.

macAddress(string $column = 'mac_address')

Create a new MAC address column on the table.

geometry(string $column, string|null $subtype = null, int $srid = 0)

Create a new geometry column on the table.

geography(string $column, string|null $subtype = null, int $srid = 4326)

Create a new geography column on the table.

computed(string $column, string $expression)

Create a new generated, computed column on the table.

vector(string $column, int|null $dimensions = null)

Create a new vector column on the table.

void
morphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table.

void
nullableMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table.

void
numericMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using numeric IDs (incremental).

void
nullableNumericMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using numeric IDs (incremental).

void
uuidMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using UUIDs.

void
nullableUuidMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using UUIDs.

void
ulidMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using ULIDs.

void
nullableUlidMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using ULIDs.

rememberToken()

Adds the remember_token column to the table.

rawColumn(string $column, string $definition)

Create a new custom column on the table.

comment(string $comment)

Add a comment to the table.

indexCommand(string $type, string|array $columns, string $index, string|null $algorithm = null)

Add a new index command to the blueprint.

dropIndexCommand(string $command, string $type, string|array $index)

Create a new drop index command on the blueprint.

string
createIndexName(string $type, array $columns)

Create a default index name for the table.

addColumn(string $type, string $name, array $parameters = [])

Add a new column to the blueprint.

addColumnDefinition(ColumnDefinition $definition)

Add a new column definition to the blueprint.

void
after(string $column, Closure $callback)

Add the columns from the callback after the given column.

$this
removeColumn(string $name)

Remove a column from the schema blueprint.

addCommand(string $name, array $parameters = [])

Add a new command to the blueprint.

createCommand(string $name, array $parameters = [])

Create a new Fluent command.

string
getTable()

Get the table the blueprint describes.

string
getPrefix()

Get the table prefix.

getColumns()

Get the columns on the blueprint.

Fluent[]
getCommands()

Get the commands on the blueprint.

getState()

Get the state of the blueprint.

getAddedColumns()

Get the columns on the blueprint that should be added.

getChangedColumns() deprecated

Get the columns on the blueprint that should be changed.

int|null
defaultTimePrecision()

Get the default time precision.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(Connection $connection, string $table, Closure|null $callback = null, string $prefix = '')

Create a new schema blueprint.

Parameters

Connection $connection
string $table
Closure|null $callback
string $prefix

Return Value

void

void build()

Execute the blueprint against the database.

Return Value

void

array toSql()

Get the raw SQL statements for the blueprint.

Return Value

array

protected void ensureCommandsAreValid()

Ensure the commands on the blueprint are valid for the connection type.

Return Value

void

Exceptions

BadMethodCallException

protected Collection commandsNamed(array $names) deprecated

deprecated Will be removed in a future Laravel version.

Get all of the commands matching the given names.

Parameters

array $names

Return Value

Collection

protected void addImpliedCommands()

Add the commands that are implied by the blueprint's state.

Return Value

void

protected void addFluentIndexes()

Add the index commands fluently specified on columns.

Return Value

void

void addFluentCommands()

Add the fluent commands specified on any columns.

Return Value

void

void addAlterCommands()

Add the alter commands if whenever needed.

Return Value

void

bool creating()

Determine if the blueprint has a create command.

Return Value

bool

Fluent create()

Indicate that the table needs to be created.

Return Value

Fluent

void engine(string $engine)

Specify the storage engine that should be used for the table.

Parameters

string $engine

Return Value

void

void innoDb()

Specify that the InnoDB storage engine should be used for the table (MySQL only).

Return Value

void

void charset(string $charset)

Specify the character set that should be used for the table.

Parameters

string $charset

Return Value

void

void collation(string $collation)

Specify the collation that should be used for the table.

Parameters

string $collation

Return Value

void

void temporary()

Indicate that the table needs to be temporary.

Return Value

void

Fluent drop()

Indicate that the table should be dropped.

Return Value

Fluent

Fluent dropIfExists()

Indicate that the table should be dropped if it exists.

Return Value

Fluent

Fluent dropColumn(array|mixed $columns)

Indicate that the given columns should be dropped.

Parameters

array|mixed $columns

Return Value

Fluent

Fluent renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

Parameters

string $from
string $to

Return Value

Fluent

Fluent dropPrimary(string|array|null $index = null)

Indicate that the given primary key should be dropped.

Parameters

string|array|null $index

Return Value

Fluent

Fluent dropUnique(string|array $index)

Indicate that the given unique key should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropIndex(string|array $index)

Indicate that the given index should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropFullText(string|array $index)

Indicate that the given fulltext index should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropSpatialIndex(string|array $index)

Indicate that the given spatial index should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropForeign(string|array $index)

Indicate that the given foreign key should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropConstrainedForeignId(string $column)

Indicate that the given column and foreign key should be dropped.

Parameters

string $column

Return Value

Fluent

Fluent dropForeignIdFor(Model|string $model, string|null $column = null)

Indicate that the given foreign key should be dropped.

Parameters

Model|string $model
string|null $column

Return Value

Fluent

Fluent dropConstrainedForeignIdFor(Model|string $model, string|null $column = null)

Indicate that the given foreign key should be dropped.

Parameters

Model|string $model
string|null $column

Return Value

Fluent

Fluent renameIndex(string $from, string $to)

Indicate that the given indexes should be renamed.

Parameters

string $from
string $to

Return Value

Fluent

void dropTimestamps()

Indicate that the timestamp columns should be dropped.

Return Value

void

void dropTimestampsTz()

Indicate that the timestamp columns should be dropped.

Return Value

void

void dropSoftDeletes(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

Parameters

string $column

Return Value

void

void dropSoftDeletesTz(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

Parameters

string $column

Return Value

void

void dropRememberToken()

Indicate that the remember token column should be dropped.

Return Value

void

void dropMorphs(string $name, string|null $indexName = null)

Indicate that the polymorphic columns should be dropped.

Parameters

string $name
string|null $indexName

Return Value

void

Fluent rename(string $to)

Rename the table to a given name.

Parameters

string $to

Return Value

Fluent

IndexDefinition primary(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify the primary key(s) for the table.

Parameters

string|array $columns
string|null $name
string|null $algorithm

Return Value

IndexDefinition

IndexDefinition unique(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify a unique index for the table.

Parameters

string|array $columns
string|null $name
string|null $algorithm

Return Value

IndexDefinition

IndexDefinition index(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify an index for the table.

Parameters

string|array $columns
string|null $name
string|null $algorithm

Return Value

IndexDefinition

IndexDefinition fullText(string|array $columns, string|null $name = null, string|null $algorithm = null)

Specify an fulltext for the table.

Parameters

string|array $columns
string|null $name
string|null $algorithm

Return Value

IndexDefinition

IndexDefinition spatialIndex(string|array $columns, string|null $name = null)

Specify a spatial index for the table.

Parameters

string|array $columns
string|null $name

Return Value

IndexDefinition

IndexDefinition rawIndex(string $expression, string $name)

Specify a raw index for the table.

Parameters

string $expression
string $name

Return Value

IndexDefinition

ForeignKeyDefinition foreign(string|array $columns, string|null $name = null)

Specify a foreign key for the table.

Parameters

string|array $columns
string|null $name

Return Value

ForeignKeyDefinition

ColumnDefinition id(string $column = 'id')

Create a new auto-incrementing big integer (8-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition increments(string $column)

Create a new auto-incrementing integer (4-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition integerIncrements(string $column)

Create a new auto-incrementing integer (4-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition tinyIncrements(string $column)

Create a new auto-incrementing tiny integer (1-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition smallIncrements(string $column)

Create a new auto-incrementing small integer (2-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition mediumIncrements(string $column)

Create a new auto-incrementing medium integer (3-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition bigIncrements(string $column)

Create a new auto-incrementing big integer (8-byte) column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition char(string $column, int|null $length = null)

Create a new char column on the table.

Parameters

string $column
int|null $length

Return Value

ColumnDefinition

ColumnDefinition string(string $column, int|null $length = null)

Create a new string column on the table.

Parameters

string $column
int|null $length

Return Value

ColumnDefinition

ColumnDefinition tinyText(string $column)

Create a new tiny text column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition text(string $column)

Create a new text column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition mediumText(string $column)

Create a new medium text column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition longText(string $column)

Create a new long text column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition integer(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new integer (4-byte) column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

ColumnDefinition tinyInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new tiny integer (1-byte) column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

ColumnDefinition smallInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new small integer (2-byte) column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

ColumnDefinition mediumInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new medium integer (3-byte) column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

ColumnDefinition bigInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new big integer (8-byte) column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

ColumnDefinition unsignedInteger(string $column, bool $autoIncrement = false)

Create a new unsigned integer (4-byte) column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

ColumnDefinition unsignedTinyInteger(string $column, bool $autoIncrement = false)

Create a new unsigned tiny integer (1-byte) column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

ColumnDefinition unsignedSmallInteger(string $column, bool $autoIncrement = false)

Create a new unsigned small integer (2-byte) column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

ColumnDefinition unsignedMediumInteger(string $column, bool $autoIncrement = false)

Create a new unsigned medium integer (3-byte) column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

ColumnDefinition unsignedBigInteger(string $column, bool $autoIncrement = false)

Create a new unsigned big integer (8-byte) column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

ForeignIdColumnDefinition foreignId(string $column)

Create a new unsigned big integer (8-byte) column on the table.

Parameters

string $column

Return Value

ForeignIdColumnDefinition

ForeignIdColumnDefinition foreignIdFor(Model|string $model, string|null $column = null)

Create a foreign ID column for the given model.

Parameters

Model|string $model
string|null $column

Return Value

ForeignIdColumnDefinition

ColumnDefinition float(string $column, int $precision = 53)

Create a new float column on the table.

Parameters

string $column
int $precision

Return Value

ColumnDefinition

ColumnDefinition double(string $column)

Create a new double column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition decimal(string $column, int $total = 8, int $places = 2)

Create a new decimal column on the table.

Parameters

string $column
int $total
int $places

Return Value

ColumnDefinition

ColumnDefinition boolean(string $column)

Create a new boolean column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition enum(string $column, array $allowed)

Create a new enum column on the table.

Parameters

string $column
array $allowed

Return Value

ColumnDefinition

ColumnDefinition set(string $column, array $allowed)

Create a new set column on the table.

Parameters

string $column
array $allowed

Return Value

ColumnDefinition

ColumnDefinition json(string $column)

Create a new json column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition jsonb(string $column)

Create a new jsonb column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition date(string $column)

Create a new date column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition dateTime(string $column, int|null $precision = null)

Create a new date-time column on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition dateTimeTz(string $column, int|null $precision = null)

Create a new date-time column (with time zone) on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition time(string $column, int|null $precision = null)

Create a new time column on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition timeTz(string $column, int|null $precision = null)

Create a new time column (with time zone) on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition timestamp(string $column, int|null $precision = null)

Create a new timestamp column on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition timestampTz(string $column, int|null $precision = null)

Create a new timestamp (with time zone) column on the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

void timestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

Parameters

int|null $precision

Return Value

void

void nullableTimestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

Alias for self::timestamps().

Parameters

int|null $precision

Return Value

void

void timestampsTz(int|null $precision = null)

Add creation and update timestampTz columns to the table.

Parameters

int|null $precision

Return Value

void

void datetimes(int|null $precision = null)

Add creation and update datetime columns to the table.

Parameters

int|null $precision

Return Value

void

ColumnDefinition softDeletes(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" timestamp for the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition softDeletesTz(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" timestampTz for the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition softDeletesDatetime(string $column = 'deleted_at', int|null $precision = null)

Add a "deleted at" datetime column to the table.

Parameters

string $column
int|null $precision

Return Value

ColumnDefinition

ColumnDefinition year(string $column)

Create a new year column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition binary(string $column, int|null $length = null, bool $fixed = false)

Create a new binary column on the table.

Parameters

string $column
int|null $length
bool $fixed

Return Value

ColumnDefinition

ColumnDefinition uuid(string $column = 'uuid')

Create a new UUID column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ForeignIdColumnDefinition foreignUuid(string $column)

Create a new UUID column on the table with a foreign key constraint.

Parameters

string $column

Return Value

ForeignIdColumnDefinition

ColumnDefinition ulid(string $column = 'ulid', int|null $length = 26)

Create a new ULID column on the table.

Parameters

string $column
int|null $length

Return Value

ColumnDefinition

ForeignIdColumnDefinition foreignUlid(string $column, int|null $length = 26)

Create a new ULID column on the table with a foreign key constraint.

Parameters

string $column
int|null $length

Return Value

ForeignIdColumnDefinition

ColumnDefinition ipAddress(string $column = 'ip_address')

Create a new IP address column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition macAddress(string $column = 'mac_address')

Create a new MAC address column on the table.

Parameters

string $column

Return Value

ColumnDefinition

ColumnDefinition geometry(string $column, string|null $subtype = null, int $srid = 0)

Create a new geometry column on the table.

Parameters

string $column
string|null $subtype
int $srid

Return Value

ColumnDefinition

ColumnDefinition geography(string $column, string|null $subtype = null, int $srid = 4326)

Create a new geography column on the table.

Parameters

string $column
string|null $subtype
int $srid

Return Value

ColumnDefinition

ColumnDefinition computed(string $column, string $expression)

Create a new generated, computed column on the table.

Parameters

string $column
string $expression

Return Value

ColumnDefinition

ColumnDefinition vector(string $column, int|null $dimensions = null)

Create a new vector column on the table.

Parameters

string $column
int|null $dimensions

Return Value

ColumnDefinition

void morphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table.

Parameters

string $name
string|null $indexName

Return Value

void

void nullableMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table.

Parameters

string $name
string|null $indexName

Return Value

void

void numericMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using numeric IDs (incremental).

Parameters

string $name
string|null $indexName

Return Value

void

void nullableNumericMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using numeric IDs (incremental).

Parameters

string $name
string|null $indexName

Return Value

void

void uuidMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using UUIDs.

Parameters

string $name
string|null $indexName

Return Value

void

void nullableUuidMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using UUIDs.

Parameters

string $name
string|null $indexName

Return Value

void

void ulidMorphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table using ULIDs.

Parameters

string $name
string|null $indexName

Return Value

void

void nullableUlidMorphs(string $name, string|null $indexName = null)

Add nullable columns for a polymorphic table using ULIDs.

Parameters

string $name
string|null $indexName

Return Value

void

ColumnDefinition rememberToken()

Adds the remember_token column to the table.

Return Value

ColumnDefinition

ColumnDefinition rawColumn(string $column, string $definition)

Create a new custom column on the table.

Parameters

string $column
string $definition

Return Value

ColumnDefinition

Fluent comment(string $comment)

Add a comment to the table.

Parameters

string $comment

Return Value

Fluent

protected Fluent indexCommand(string $type, string|array $columns, string $index, string|null $algorithm = null)

Add a new index command to the blueprint.

Parameters

string $type
string|array $columns
string $index
string|null $algorithm

Return Value

Fluent

protected Fluent dropIndexCommand(string $command, string $type, string|array $index)

Create a new drop index command on the blueprint.

Parameters

string $command
string $type
string|array $index

Return Value

Fluent

protected string createIndexName(string $type, array $columns)

Create a default index name for the table.

Parameters

string $type
array $columns

Return Value

string

ColumnDefinition addColumn(string $type, string $name, array $parameters = [])

Add a new column to the blueprint.

Parameters

string $type
string $name
array $parameters

Return Value

ColumnDefinition

protected ColumnDefinition addColumnDefinition(ColumnDefinition $definition)

Add a new column definition to the blueprint.

Parameters

ColumnDefinition $definition

Return Value

ColumnDefinition

void after(string $column, Closure $callback)

Add the columns from the callback after the given column.

Parameters

string $column
Closure $callback

Return Value

void

$this removeColumn(string $name)

Remove a column from the schema blueprint.

Parameters

string $name

Return Value

$this

protected Fluent addCommand(string $name, array $parameters = [])

Add a new command to the blueprint.

Parameters

string $name
array $parameters

Return Value

Fluent

protected Fluent createCommand(string $name, array $parameters = [])

Create a new Fluent command.

Parameters

string $name
array $parameters

Return Value

Fluent

string getTable()

Get the table the blueprint describes.

Return Value

string

string getPrefix()

Get the table prefix.

Return Value

string

ColumnDefinition[] getColumns()

Get the columns on the blueprint.

Return Value

ColumnDefinition[]

Fluent[] getCommands()

Get the commands on the blueprint.

Return Value

Fluent[]

BlueprintState getState()

Get the state of the blueprint.

Return Value

BlueprintState

ColumnDefinition[] getAddedColumns()

Get the columns on the blueprint that should be added.

Return Value

ColumnDefinition[]

ColumnDefinition[] getChangedColumns() deprecated

deprecated Will be removed in a future Laravel version.

Get the columns on the blueprint that should be changed.

Return Value

ColumnDefinition[]

protected int|null defaultTimePrecision()

Get the default time precision.

Return Value

int|null