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.
Create an auto-incrementing column using an unsigned BIGINT
type. This column is also set as the primary key for the table.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a BIGINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a BIT
equivalent type for your database. The length can be specified as the second argument.
Example (default length):
SchemaBuilder
SQL (MySQL)
Example (custom length):
SchemaBuilder
SQL (MySQL)
Create a column using a BOOLEAN
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a CHAR
equivalent type for your database.
Example (default length):
SchemaBuilder
SQL (MySQL)
Example (custom length):
SchemaBuilder
SQL (MySQL)
Create a column using a DATE
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a DATETIME
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a DECIMAL
equivalent type for your database. The length and precision can be specified as the second and third arguments.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a ENUM
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a FLOAT
equivalent type for your database. The length and precision can be specified as the second and third arguments.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create an auto-incrementing column using an unsigned INTEGER
type. This column is also set as the primary key for the table.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a INTEGER
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a JSON
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a LONGTEXT
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create an auto-incrementing column using an unsigned MEDIUMINT
type. This column is also set as the primary key for the table.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a MEDIUMINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
An escape hatch to directly insert any sql in to the statement.
Example:
SchemaBuilder
SQL (MySQL)
Create an auto-incrementing column using an unsigned SMALLINT
type. This column is also set as the primary key for the table.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a SMALLINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
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.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a TIME
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a TIMESTAMP
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
Create an auto-incrementing column using an unsigned TINYINT
type. This column is also set as the primary key for the table.
Example:
SchemaBuilder
SQL (MySQL)
Create a column using a TINYINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
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.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
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.
Example (with defaults):
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
Example (with length):
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
Create a column using a NTEXT
equivalent type for your database.
Example:
SchemaBuilder
SQL (MySQL)
SQL (MSSQL)
Create a column using a UNSIGNED BIGINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a UNSIGNED INTEGER
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a UNSIGNED MEDIUMINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a UNSIGNED SMALLINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
Create a column using a UNSIGNED TINYINT
equivalent type for your database.
Example (no precision):
SchemaBuilder
SQL (MySQL)
Example (with precision):
SchemaBuilder
SQL (MySQL)
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.
Example:
SchemaBuilder
MySQL (SQL Server)
SQL (MySQL)
Columns
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
1
The length for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
1
The length for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
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.
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
10
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The prefix for the polymorphic columns.
Argument
Type
Required
Default
Description
name
string
true
The prefix for the polymorphic columns.
Argument
Type
Required
Default
Description
sql
string
true
The sql to insert directly into the statement.
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
255
The length of the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
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.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
length
numeric
false
255
The length of the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.
precision
numeric
false
The precision for the column.
Argument
Type
Required
Default
Description
name
string
true
The name for the column.