Columns
The Blueprint
object has many column types available to construct your table schema. Additionally, you can modify the columns created with an additional set of methods and indexes.
Columns
bigIncrements
Create an auto-incrementing column using an unsigned BIGINT
type. This column is also set as the primary key for the table.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
indexName
string
false
The name for the primary key index. If no name is passed in, the name will be dynamically created based off of the table name and column name.
Example:
SchemaBuilder
SQL (MySQL)
bigInteger
Create a column using a BIGINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
bit
Create a column using a BIT
equivalent type for your database. The length can be specified as the second argument.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
1
The length for the column.
Example (default length):
SchemaBuilder
SQL (MySQL)
Example (custom length):
SchemaBuilder
SQL (MySQL)
boolean
Create a column using a BOOLEAN
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
char
Create a column using a CHAR
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
1
The length for the column.
Example (default length):
SchemaBuilder
SQL (MySQL)
Example (custom length):
SchemaBuilder
SQL (MySQL)
date
Create a column using a DATE
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
datetime
Create a column using a DATETIME
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
decimal
Create a column using a DECIMAL
equivalent type for your database. The length and precision can be specified as the second and third arguments.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
10
The length of the column.
precision
numeric
false
0
The precision of the column.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
enum
Create a column using a ENUM
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
float
Create a column using a FLOAT
equivalent type for your database. The length and precision can be specified as the second and third arguments.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
10
The length of the column.
precision
numeric
false
0
The precision of the column.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
increments
Create an auto-incrementing column using an unsigned INTEGER
type. This column is also set as the primary key for the table.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
indexName
string
false
The name for the primary key index. If no name is passed in, the name will be dynamically created based off of the table name and column name.
Example:
SchemaBuilder
SQL (MySQL)
integer
Create a column using a INTEGER
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
json
Create a column using a JSON
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
longText
Create a column using a LONGTEXT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
mediumIncrements
Create an auto-incrementing column using an unsigned MEDIUMINT
type. This column is also set as the primary key for the table.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
indexName
string
false
The name for the primary key index. If no name is passed in, the name will be dynamically created based off of the table name and column name.
Example:
SchemaBuilder
SQL (MySQL)
mediumInteger
Create a column using a MEDIUMINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
10
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
mediumText
Create a column using a MEDIUMTEXT
equivalent type for your database. For databases that distinguish between unicode and non-unicode fields, creates a non-unicode field.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
morphs
Creates the necessary columns for a polymorphic relationship. It takes the name provided and creates an _id
and an _type
column.
If you want different names for your polymorphic relationship columns, feel free to call other schema builder methods individually.
Argument
Type
Required
Default
Description
name
string
true
The prefix for the polymorphic columns.
Example:
SchemaBuilder
SQL (MySQL)
nullableMorphs
Creates the necessary columns for a polymorphic relationship. It takes the name provided and creates an _id
and an _type
column. The only difference between this method and morphs
is that the columns created here are nullable.
If you want different names for your polymorphic relationship columns, feel free to call other schema builder methods individually.
Argument
Type
Required
Default
Description
name
string
true
The prefix for the polymorphic columns.
Example:
SchemaBuilder
SQL (MySQL)
raw
An escape hatch to directly insert any sql in to the statement.
Argument
Type
Required
Default
Description
sql
string
true
The sql to insert directly into the statement.
Example:
SchemaBuilder
SQL (MySQL)
smallIncrements
Create an auto-incrementing column using an unsigned SMALLINT
type. This column is also set as the primary key for the table.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
indexName
string
false
The name for the primary key index. If no name is passed in, the name will be dynamically created based off of the table name and column name.
Example:
SchemaBuilder
SQL (MySQL)
smallInteger
Create a column using a SMALLINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
string
Create a column using a VARCHAR
equivalent type for your database. For databases that distinguish between unicode- and non-unicode string data types, this function will create a non-unicode string.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
255
The length of the column.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
text
Create a column using a TEXT
equivalent type for your database. For databases that distinguish between unicode- and non-unicode string data types, this function will create a non-unicode text field.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
time
Create a column using a TIME
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
timestamp
Create a column using a TIMESTAMP
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
tinyIncrements
Create an auto-incrementing column using an unsigned TINYINT
type. This column is also set as the primary key for the table.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
indexName
string
false
The name for the primary key index. If no name is passed in, the name will be dynamically created based off of the table name and column name.
Example:
SchemaBuilder
SQL (MySQL)
tinyInteger
Create a column using a TINYINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
unicodeLongText
Create a column using a LONGTEXT
equivalent type for your database. For databases that distinguish between unicode- and non-unicode string data types, this function will create a unicode text field.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
unicodeMediumText
Create a unicode-enabled column using a MEDIUMTEXT
equivalent type for your database. For databases that distinguish between unicode- and non-unicode string data types, this function will create a unicode text field.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
unicodeString
Create a column using a NVARCHAR
equivalent type for your database. For databases that distinguish between unicode- and non-unicode string data types, this function will create a unicode string.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
255
The length of the column.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
unicodeText
Create a column using a NTEXT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
unsignedBigInteger
Create a column using a UNSIGNED BIGINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
unsignedInteger
Create a column using a UNSIGNED INTEGER
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
unsignedMediumInteger
Create a column using a UNSIGNED MEDIUMINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
unsignedSmallInteger
Create a column using a UNSIGNED SMALLINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
unsignedTinyInteger
Create a column using a UNSIGNED TINYINT
equivalent type for your database.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
uuid
SQL Server: Create a column using a uniqueidentifier
.
MySQL and Others: Create a column using a CHAR
equivalent type for your database and a length of 36. Used in conjunction with the CFML createUUID
method.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Example:
SchemaBuilder
MySQL (SQL Server)
SQL (MySQL)
Last updated