class Blueprint

Traits

Constants

private FOREIGN_KEY_TARGET_COMMANDS

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected Connection $connection

The database connection instance.

protected Grammar $grammar

The schema grammar instance.

protected string $table

The table the blueprint describes.

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|null $engine

The storage engine that should be used for the table.

string|null $charset

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

string|null $collation

The collation that should be used for the table.

bool $temporary

Whether to make the table temporary.

string|null $after

The column to add new columns after.

protected BlueprintState|null $state

The blueprint state instance.

Methods

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

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

Check 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.

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

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.

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|string $columns)

Indicate that the given columns should be dropped.

renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

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

Indicate that the given primary key should be dropped.

dropUnique(array|string $index)

Indicate that the given unique key should be dropped.

dropIndex(array|string $index)

Indicate that the given index should be dropped.

dropFullText(array|string $index)

Indicate that the given fulltext index should be dropped.

dropSpatialIndex(array|string $index)

Indicate that the given spatial index should be dropped.

dropVectorIndex(array|string $index)

Indicate that the given vector index should be dropped.

dropForeign(array|string $index, string|null $name = null)

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(array|string $columns, string|null $name = null, string|null $algorithm = null)

Specify the primary key(s) for the table.

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

Specify a unique index for the table.

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

Specify an index for the table.

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

Specify a fulltext index for the table.

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

Specify a spatial index for the table.

vectorIndex(string $column, string|null $name = null)

Specify a vector index for the table.

rawIndex(string $expression, string $name)

Specify a raw index for the table.

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

Specify a foreign key for the table.

id(string $column = 'id')

Create a new auto-incrementing big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

increments(string $column)

Create a new auto-incrementing integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

integerIncrements(string $column)

Create a new auto-incrementing integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

tinyIncrements(string $column)

Create a new auto-incrementing tiny integer column on the table (MySQL/MariaDB: 1-byte, 0 to 255).

smallIncrements(string $column)

Create a new auto-incrementing small integer column on the table (MySQL/MariaDB: 2-byte, 0 to 65,535).

mediumIncrements(string $column)

Create a new auto-incrementing medium integer column on the table (MySQL/MariaDB: 3-byte, 0 to 16,777,215).

bigIncrements(string $column)

Create a new auto-incrementing big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

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 (up to 255 bytes on MySQL/MariaDB).

text(string $column)

Create a new text column on the table (up to 65,535 bytes on MySQL/MariaDB).

mediumText(string $column)

Create a new medium text column on the table (up to 16,777,215 bytes on MySQL/MariaDB).

longText(string $column)

Create a new long text column on the table (up to 4,294,967,295 bytes on MySQL/MariaDB).

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

Create a new integer column on the table.

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

Create a new tiny integer column on the table.

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

Create a new small integer column on the table.

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

Create a new medium integer column on the table.

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

Create a new big integer column on the table.

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

Create a new unsigned integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

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

Create a new unsigned tiny integer column on the table (MySQL/MariaDB: 1-byte, 0 to 255).

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

Create a new unsigned small integer column on the table (MySQL/MariaDB: 2-byte, 0 to 65,535).

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

Create a new unsigned medium integer column on the table (MySQL/MariaDB: 3-byte, 0 to 16,777,215).

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

Create a new unsigned big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

foreignId(string $column)

Create a new unsigned big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

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

Create a foreign ID column for the given model.

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

Create a foreign UUID column for the given model.

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

Create a foreign ULID 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.

timestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

nullableTimestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

timestampsTz(int|null $precision = null)

Add nullable creation and update timestampTz columns to the table.

nullableTimestampsTz(int|null $precision = null)

Add nullable creation and update timestampTz columns to the table.

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 foreign ID column on the table.

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 foreign ID column on the table.

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.

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

Create a new vector column on the table.

tsvector(string $column)

Create a new tsvector column on the table.

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

Add the proper columns for a polymorphic table.

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

Add nullable columns for a polymorphic table.

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

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

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

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

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

Add the proper columns for a polymorphic table using UUIDs.

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

Add nullable columns for a polymorphic table using UUIDs.

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

Add the proper columns for a polymorphic table using ULIDs.

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

Add nullable columns for a polymorphic table using ULIDs.

rememberToken()

Add 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, array|string $columns, string|null $index, string|null $algorithm = null, string|null $operatorClass = null)

Create a new index command on the blueprint.

dropIndexCommand(string $command, string $type, array|string|null $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.

newColumnDefinition(array $attributes)

Create a new column definition.

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.

removeColumn(string $name)

Remove a column from the schema blueprint.

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

Add a new command to the blueprint.

addCommandDefinition(Fluent $definition)

Add a new command definition to the blueprint.

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

Create a new Fluent command.

string
getTable()

Get the table the blueprint describes.

getGrammar()

Get the schema grammar used by the blueprint.

array
getColumns()

Get the columns on the blueprint.

array
getCommands()

Get the commands on the blueprint.

getState()

Get the state of the blueprint.

array
getAddedColumns()

Get the columns on the blueprint that should be added.

int|null
defaultTimePrecision()

Get the default time precision.

static void
flushState()

Flush all static state.

Details

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 97
__construct(Connection $connection, string $table, Closure|null $callback = null)

Create a new schema blueprint.

Parameters

Connection $connection
string $table
Closure|null $callback

at line 111
void build()

Execute the blueprint against the database.

Return Value

void

at line 119
array toSql()

Get the raw SQL statements for the blueprint.

Return Value

array

at line 156
protected void ensureCommandsAreValid()

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

Return Value

void

Exceptions

BadMethodCallException

at line 166
protected void addImpliedCommands()

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

Return Value

void

at line 188
protected void addFluentIndexes()

Add the index commands fluently specified on columns.

Return Value

void

at line 335
void addFluentCommands()

Add the fluent commands specified on any columns.

Return Value

void

at line 347
void addAlterCommands()

Add the alter commands if whenever needed.

Return Value

void

at line 385
bool creating()

Determine if the blueprint has a create command.

Return Value

bool

at line 394
Fluent create()

Indicate that the table needs to be created.

Return Value

Fluent

at line 402
void engine(string $engine)

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

Parameters

string $engine

Return Value

void

at line 410
void innoDb()

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

Return Value

void

at line 418
void charset(string $charset)

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

Parameters

string $charset

Return Value

void

at line 426
void collation(string $collation)

Specify the collation that should be used for the table.

Parameters

string $collation

Return Value

void

at line 434
void temporary()

Indicate that the table needs to be temporary.

Return Value

void

at line 442
Fluent drop()

Indicate that the table should be dropped.

Return Value

Fluent

at line 450
Fluent dropIfExists()

Indicate that the table should be dropped if it exists.

Return Value

Fluent

at line 458
Fluent dropColumn(array|string $columns)

Indicate that the given columns should be dropped.

Parameters

array|string $columns

Return Value

Fluent

at line 468
Fluent renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

Parameters

string $from
string $to

Return Value

Fluent

at line 476
Fluent dropPrimary(array|string|null $index = null)

Indicate that the given primary key should be dropped.

Parameters

array|string|null $index

Return Value

Fluent

at line 484
Fluent dropUnique(array|string $index)

Indicate that the given unique key should be dropped.

Parameters

array|string $index

Return Value

Fluent

at line 492
Fluent dropIndex(array|string $index)

Indicate that the given index should be dropped.

Parameters

array|string $index

Return Value

Fluent

at line 500
Fluent dropFullText(array|string $index)

Indicate that the given fulltext index should be dropped.

Parameters

array|string $index

Return Value

Fluent

at line 508
Fluent dropSpatialIndex(array|string $index)

Indicate that the given spatial index should be dropped.

Parameters

array|string $index

Return Value

Fluent

at line 516
Fluent dropVectorIndex(array|string $index)

Indicate that the given vector index should be dropped.

Parameters

array|string $index

Return Value

Fluent

at line 524
Fluent dropForeign(array|string $index, string|null $name = null)

Indicate that the given foreign key should be dropped.

Parameters

array|string $index
string|null $name

Return Value

Fluent

at line 540
Fluent dropConstrainedForeignId(string $column)

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

Parameters

string $column

Return Value

Fluent

at line 550
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

at line 562
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

at line 574
Fluent renameIndex(string $from, string $to)

Indicate that the given indexes should be renamed.

Parameters

string $from
string $to

Return Value

Fluent

at line 582
void dropTimestamps()

Indicate that the timestamp columns should be dropped.

Return Value

void

at line 590
void dropTimestampsTz()

Indicate that the timestamp columns should be dropped.

Return Value

void

at line 598
void dropSoftDeletes(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

Parameters

string $column

Return Value

void

at line 606
void dropSoftDeletesTz(string $column = 'deleted_at')

Indicate that the soft delete column should be dropped.

Parameters

string $column

Return Value

void

at line 614
void dropRememberToken()

Indicate that the remember token column should be dropped.

Return Value

void

at line 622
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

at line 636
Fluent rename(string $to)

Rename the table to a given name.

Parameters

string $to

Return Value

Fluent

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

Specify the primary key(s) for the table.

Parameters

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

Return Value

IndexDefinition

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

Specify a unique index for the table.

Parameters

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

Return Value

IndexDefinition

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

Specify an index for the table.

Parameters

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

Return Value

IndexDefinition

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

Specify a fulltext index for the table.

Parameters

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

Return Value

IndexDefinition

at line 676
IndexDefinition spatialIndex(array|string $columns, string|null $name = null, string|null $operatorClass = null)

Specify a spatial index for the table.

Parameters

array|string $columns
string|null $name
string|null $operatorClass

Return Value

IndexDefinition

at line 684
IndexDefinition vectorIndex(string $column, string|null $name = null)

Specify a vector index for the table.

Parameters

string $column
string|null $name

Return Value

IndexDefinition

at line 696
IndexDefinition rawIndex(string $expression, string $name)

Specify a raw index for the table.

Parameters

string $expression
string $name

Return Value

IndexDefinition

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

Specify a foreign key for the table.

Parameters

array|string $columns
string|null $name

Return Value

ForeignKeyDefinition

at line 722
ColumnDefinition id(string $column = 'id')

Create a new auto-incrementing big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

Parameters

string $column

Return Value

ColumnDefinition

at line 732
ColumnDefinition increments(string $column)

Create a new auto-incrementing integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

Parameters

string $column

Return Value

ColumnDefinition

at line 742
ColumnDefinition integerIncrements(string $column)

Create a new auto-incrementing integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

Parameters

string $column

Return Value

ColumnDefinition

at line 752
ColumnDefinition tinyIncrements(string $column)

Create a new auto-incrementing tiny integer column on the table (MySQL/MariaDB: 1-byte, 0 to 255).

Parameters

string $column

Return Value

ColumnDefinition

at line 762
ColumnDefinition smallIncrements(string $column)

Create a new auto-incrementing small integer column on the table (MySQL/MariaDB: 2-byte, 0 to 65,535).

Parameters

string $column

Return Value

ColumnDefinition

at line 772
ColumnDefinition mediumIncrements(string $column)

Create a new auto-incrementing medium integer column on the table (MySQL/MariaDB: 3-byte, 0 to 16,777,215).

Parameters

string $column

Return Value

ColumnDefinition

at line 782
ColumnDefinition bigIncrements(string $column)

Create a new auto-incrementing big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

Parameters

string $column

Return Value

ColumnDefinition

at line 792
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

at line 804
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

at line 816
ColumnDefinition tinyText(string $column)

Create a new tiny text column on the table (up to 255 bytes on MySQL/MariaDB).

Parameters

string $column

Return Value

ColumnDefinition

at line 826
ColumnDefinition text(string $column)

Create a new text column on the table (up to 65,535 bytes on MySQL/MariaDB).

Parameters

string $column

Return Value

ColumnDefinition

at line 836
ColumnDefinition mediumText(string $column)

Create a new medium text column on the table (up to 16,777,215 bytes on MySQL/MariaDB).

Parameters

string $column

Return Value

ColumnDefinition

at line 846
ColumnDefinition longText(string $column)

Create a new long text column on the table (up to 4,294,967,295 bytes on MySQL/MariaDB).

Parameters

string $column

Return Value

ColumnDefinition

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

Create a new integer column on the table.

MySQL/MariaDB (4-byte): -2,147,483,648 to 2,147,483,647 (signed) or 0 to 4,294,967,295 (unsigned).

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

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

Create a new tiny integer column on the table.

MySQL/MariaDB (1-byte): -128 to 127 (signed) or 0 to 255 (unsigned).

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

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

Create a new small integer column on the table.

MySQL/MariaDB (2-byte): -32,768 to 32,767 (signed) or 0 to 65,535 (unsigned).

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

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

Create a new medium integer column on the table.

MySQL/MariaDB (3-byte): -8,388,608 to 8,388,607 (signed) or 0 to 16,777,215 (unsigned).

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

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

Create a new big integer column on the table.

MySQL/MariaDB (8-byte): -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed) or 0 to 18,446,744,073,709,551,615 (unsigned).

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

ColumnDefinition

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

Create a new unsigned integer column on the table (MySQL/MariaDB: 4-byte, 0 to 4,294,967,295).

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

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

Create a new unsigned tiny integer column on the table (MySQL/MariaDB: 1-byte, 0 to 255).

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

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

Create a new unsigned small integer column on the table (MySQL/MariaDB: 2-byte, 0 to 65,535).

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

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

Create a new unsigned medium integer column on the table (MySQL/MariaDB: 3-byte, 0 to 16,777,215).

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

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

Create a new unsigned big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

Parameters

string $column
bool $autoIncrement

Return Value

ColumnDefinition

at line 959
ForeignIdColumnDefinition foreignId(string $column)

Create a new unsigned big integer column on the table (MySQL/MariaDB: 8-byte, 0 to 18,446,744,073,709,551,615).

Parameters

string $column

Return Value

ForeignIdColumnDefinition

at line 972
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

at line 1000
ForeignIdColumnDefinition foreignUuidFor(Model|string $model, string|null $column = null)

Create a foreign UUID column for the given model.

Parameters

Model|string $model
string|null $column

Return Value

ForeignIdColumnDefinition

at line 1014
ForeignIdColumnDefinition foreignUlidFor(Model|string $model, string|null $column = null)

Create a foreign ULID column for the given model.

Parameters

Model|string $model
string|null $column

Return Value

ForeignIdColumnDefinition

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

Create a new float column on the table.

Parameters

string $column
int $precision

Return Value

ColumnDefinition

at line 1040
ColumnDefinition double(string $column)

Create a new double column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1050
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

at line 1060
ColumnDefinition boolean(string $column)

Create a new boolean column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1070
ColumnDefinition enum(string $column, array $allowed)

Create a new enum column on the table.

Parameters

string $column
array $allowed

Return Value

ColumnDefinition

at line 1082
ColumnDefinition set(string $column, array $allowed)

Create a new set column on the table.

Parameters

string $column
array $allowed

Return Value

ColumnDefinition

at line 1092
ColumnDefinition json(string $column)

Create a new json column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1102
ColumnDefinition jsonb(string $column)

Create a new jsonb column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1112
ColumnDefinition date(string $column)

Create a new date column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1122
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

at line 1134
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

at line 1146
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

at line 1158
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

at line 1170
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

at line 1182
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

at line 1194
Collection timestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

Parameters

int|null $precision

Return Value

Collection

at line 1209
Collection nullableTimestamps(int|null $precision = null)

Add nullable creation and update timestamps to the table.

Alias for self::timestamps().

Parameters

int|null $precision

Return Value

Collection

at line 1219
Collection timestampsTz(int|null $precision = null)

Add nullable creation and update timestampTz columns to the table.

Parameters

int|null $precision

Return Value

Collection

at line 1234
Collection nullableTimestampsTz(int|null $precision = null)

Add nullable creation and update timestampTz columns to the table.

Alias for self::timestampsTz().

Parameters

int|null $precision

Return Value

Collection

at line 1244
Collection datetimes(int|null $precision = null)

Add creation and update datetime columns to the table.

Parameters

int|null $precision

Return Value

Collection

at line 1257
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

at line 1267
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

at line 1277
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

at line 1287
ColumnDefinition year(string $column)

Create a new year column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1297
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

at line 1307
ColumnDefinition uuid(string $column = 'uuid')

Create a new UUID column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1315
ForeignIdColumnDefinition foreignUuid(string $column)

Create a new UUID foreign ID column on the table.

Parameters

string $column

Return Value

ForeignIdColumnDefinition

at line 1328
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

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

Create a new ULID foreign ID column on the table.

Parameters

string $column
int|null $length

Return Value

ForeignIdColumnDefinition

at line 1350
ColumnDefinition ipAddress(string $column = 'ip_address')

Create a new IP address column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1360
ColumnDefinition macAddress(string $column = 'mac_address')

Create a new MAC address column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1370
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

at line 1380
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

at line 1392
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

at line 1404
ColumnDefinition tsvector(string $column)

Create a new tsvector column on the table.

Parameters

string $column

Return Value

ColumnDefinition

at line 1412
void morphs(string $name, string|null $indexName = null, string|null $after = null)

Add the proper columns for a polymorphic table.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1426
void nullableMorphs(string $name, string|null $indexName = null, string|null $after = null)

Add nullable columns for a polymorphic table.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1440
void numericMorphs(string $name, string|null $indexName = null, string|null $after = null)

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

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1454
void nullableNumericMorphs(string $name, string|null $indexName = null, string|null $after = null)

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

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1470
void uuidMorphs(string $name, string|null $indexName = null, string|null $after = null)

Add the proper columns for a polymorphic table using UUIDs.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1484
void nullableUuidMorphs(string $name, string|null $indexName = null, string|null $after = null)

Add nullable columns for a polymorphic table using UUIDs.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1500
void ulidMorphs(string $name, string|null $indexName = null, string|null $after = null)

Add the proper columns for a polymorphic table using ULIDs.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1514
void nullableUlidMorphs(string $name, string|null $indexName = null, string|null $after = null)

Add nullable columns for a polymorphic table using ULIDs.

Parameters

string $name
string|null $indexName
string|null $after

Return Value

void

at line 1532
ColumnDefinition rememberToken()

Add the remember_token column to the table.

Return Value

ColumnDefinition

at line 1542
ColumnDefinition rawColumn(string $column, string $definition)

Create a new custom column on the table.

Parameters

string $column
string $definition

Return Value

ColumnDefinition

at line 1550
Fluent comment(string $comment)

Add a comment to the table.

Parameters

string $comment

Return Value

Fluent

at line 1558
protected IndexDefinition indexCommand(string $type, array|string $columns, string|null $index, string|null $algorithm = null, string|null $operatorClass = null)

Create a new index command on the blueprint.

Parameters

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

Return Value

IndexDefinition

at line 1577
protected Fluent dropIndexCommand(string $command, string $type, array|string|null $index)

Create a new drop index command on the blueprint.

Parameters

string $command
string $type
array|string|null $index

Return Value

Fluent

at line 1594
protected string createIndexName(string $type, array $columns)

Create a default index name for the table.

Parameters

string $type
array $columns

Return Value

string

at line 1614
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

at line 1626
protected ColumnDefinition newColumnDefinition(array $attributes)

Create a new column definition.

Parameters

array $attributes

Return Value

ColumnDefinition

at line 1639
protected ColumnDefinition addColumnDefinition(ColumnDefinition $definition)

Add a new column definition to the blueprint.

Parameters

ColumnDefinition $definition

Return Value

ColumnDefinition

at line 1662
void after(string $column, Closure $callback)

Add the columns from the callback after the given column.

Parameters

string $column
Closure $callback

Return Value

void

at line 1674
Blueprint removeColumn(string $name)

Remove a column from the schema blueprint.

Parameters

string $name

Return Value

Blueprint

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

Add a new command to the blueprint.

Parameters

string $name
array $parameters

Return Value

Fluent

at line 1705
protected Fluent addCommandDefinition(Fluent $definition)

Add a new command definition to the blueprint.

Parameters

Fluent $definition

Return Value

Fluent

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

Create a new Fluent command.

Parameters

string $name
array $parameters

Return Value

Fluent

at line 1723
string getTable()

Get the table the blueprint describes.

Return Value

string

at line 1731
Grammar getGrammar()

Get the schema grammar used by the blueprint.

Return Value

Grammar

at line 1744
array getColumns()

Get the columns on the blueprint.

Return Value

array

at line 1754
array getCommands()

Get the commands on the blueprint.

Return Value

array

at line 1770
BlueprintState|null getState()

Get the state of the blueprint.

Return Value

BlueprintState|null

at line 1780
array getAddedColumns()

Get the columns on the blueprint that should be added.

Return Value

array

at line 1793
protected int|null defaultTimePrecision()

Get the default time precision.

Return Value

int|null

at line 1801
static void flushState()

Flush all static state.

Return Value

void