class Illuminate / Database / Schema / Builder

Builder

Properties

protected

$connection Connection

The database connection instance.

Default: null
protected

$grammar Grammar

The schema grammar instance.

Default: null
protected

$resolver Closure

The Blueprint resolver callback.

Default: null
public static

$defaultStringLength int|null

The default string length for migrations.

Default: 255
public static

$defaultMorphKeyType string

The default relationship morph key type.

Default: 'int'
public static

$alwaysUsesNativeSchemaOperationsIfPossible bool

Indicates whether Doctrine DBAL usage will be prevented if possible when dropping, renaming, and modifying columns.

Default: false

Methods

public

__construct ( Connection $connection ) : void

Create a new database Schema manager.

Parameters

public static

defaultStringLength ( $length ) : void

Set the default string length for migrations.

Parameters

  • $length int
public static

defaultMorphKeyType ( string $type ) : void

Set the default morph key type for migrations.

Parameters

  • $type string
public static

morphUsingUuids ( ) : void

Set the default morph key type for migrations to UUIDs.

public static

morphUsingUlids ( ) : void

Set the default morph key type for migrations to ULIDs.

public static

useNativeSchemaOperationsIfPossible ( bool $value ) : void

Attempt to use native schema operations for dropping, renaming, and modifying columns, even if Doctrine DBAL is installed.

Parameters

  • $value bool
public

createDatabase ( $name ) : bool

Create a database in the schema.

Parameters

  • $name string
public

dropDatabaseIfExists ( $name ) : bool

Drop a database from the schema if the database exists.

Parameters

  • $name string
public

hasTable ( $table ) : bool

Determine if the given table exists.

Parameters

  • $table string
public

hasColumn ( $table , $column ) : bool

Determine if the given table has a given column.

Parameters

  • $table string
  • $column string
public

hasColumns ( $table , array $columns ) : bool

Determine if the given table has given columns.

Parameters

  • $table string
  • $columns array
public

whenTableHasColumn ( string $table , string $column , Closure $callback ) : void

Execute a table builder callback if the given table has a given column.

Parameters

  • $table string
  • $column string
  • $callback Closure
public

whenTableDoesntHaveColumn ( string $table , string $column , Closure $callback ) : void

Execute a table builder callback if the given table doesn't have a given column.

Parameters

  • $table string
  • $column string
  • $callback Closure
public

getColumnType ( $table , $column ) : string

Get the data type for the given column name.

Parameters

  • $table string
  • $column string
public

getColumnListing ( $table ) : array

Get the column listing for a given table.

Parameters

  • $table string
public

table ( $table , Closure $callback ) : void

Modify a table on the schema.

Parameters

public

create ( $table , Closure $callback ) : void

Create a new table on the schema.

Parameters

public

drop ( $table ) : void

Drop a table from the schema.

Parameters

  • $table string
public

dropIfExists ( $table ) : void

Drop a table from the schema if it exists.

Parameters

  • $table string
public

dropColumns ( $table , $columns ) : void

Drop columns from a table schema.

Parameters

  • $table string
  • $columns string|array
public

dropAllTables ( ) : void

Drop all tables from the database.

public

dropAllViews ( ) : void

Drop all views from the database.

public

dropAllTypes ( ) : void

Drop all types from the database.

public

getAllTables ( ) : array

Get all of the table names for the database.

public

rename ( $from , $to ) : void

Rename a table on the schema.

Parameters

  • $from string
  • $to string
public

enableForeignKeyConstraints ( ) : bool

Enable foreign key constraints.

public

disableForeignKeyConstraints ( ) : bool

Disable foreign key constraints.

public

withoutForeignKeyConstraints ( Closure $callback ) : mixed

Disable foreign key constraints during the execution of a callback.

Parameters

protected

build ( Blueprint $blueprint ) : void

Execute the blueprint to build / modify the table.

Parameters

protected

createBlueprint ( $table , Closure $callback ) : Blueprint

Create a new command set with a Closure.

Parameters

public

getConnection ( ) : Connection

Get the database connection instance.

public

setConnection ( Connection $connection ) : $this

Set the database connection instance.

Parameters

public

blueprintResolver ( Closure $resolver ) : void

Set the Schema Blueprint resolver callback.

Parameters