Migrator
text()
Signature
Section titled “Signature”text() — returns any
Available in: tabledefinition
Category: Table Definition Functions
Description
Section titled “Description”Used within a migration to add one or more text columns to a database table definition. Text columns are designed for storing larger amounts of character data compared to standard string or varchar columns. This function allows you to define the column name, set a default value, and control whether the column allows null values.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columnNames | string | no | — | |
default | string | no | — | |
allowNull | boolean | no | — |
Examples
Section titled “Examples”1. In a migration file
t.text("description");
2. Creates both summary and notes columns as text types
t.text("summary,notes");
3. Adds a column with a default placeholder text
t.text(columnNames="details", default="N/A");
4. Adds a text column that must always have a value
t.text(columnNames="bio", allowNull=false);
5. Adds a column with a default value and disallows nulls
t.text(columnNames="comments", default="No comments provided", allowNull=false);