Migrator
float()
Signature
Section titled “Signature”float() — returns any
Available in: tabledefinition
Category: Table Definition Functions
Description
Section titled “Description”The float() function is used in a table definition during a migration to add one or more float-type columns to a database table. You can specify column names, default values, and whether the columns allow NULL. This helps define numeric columns with decimal values in your schema. Only available in a migrator CFC.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columnNames | string | no | — | |
default | string | no | — | |
allowNull | boolean | no | true |
Examples
Section titled “Examples”1. Basic usage: add a single float column
t.float("price");
2. Add multiple float columns at once
t.float("length,width,height");
3. Add a float column with a default value
t.float(columnNames="discount", default="0.0");
4. Add a float column that cannot be null
t.float(columnNames="taxRate", allowNull=false);
5. Add multiple float columns with defaults
t.float(columnNames="latitude,longitude", default="0.0");
6. Combine default value and null constraint
t.float(columnNames="weight", default="1.0", allowNull=false);