Migrator
string()
Signature
Section titled “Signature”string() — returns any
Available in: tabledefinition
Category: Table Definition Functions
Description
Section titled “Description”Used to add one or more string (VARCHAR) columns to a database table. It supports specifying default values, nullability, and a maximum length (limit). Only available in a migrator CFC.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columnNames | string | no | — | |
limit | any | no | — | |
default | string | no | — | |
allowNull | boolean | no | — |
Examples
Section titled “Examples”1. Add a simple string column
t.string("username");
2. Limit the length of the string
t.string(columnNames="email", limit=255);
3. Set default values
t.string(columnNames="status", default="active");
4. Multiple columns in one call
t.string(columnNames="firstName,lastName");
5. Nullable vs non-nullable
t.string(columnNames="configKey", allowNull=false);
t.string(columnNames="configValue", allowNull=true);