Migrator
float()
Signature
Section titled “Signature”float() — returns any
Available in: tabledefinition
Category: Table Definition Functions
Description
Section titled “Description”adds float columns to table definition
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columnNames | string | no | — | |
default | any | no | — | |
allowNull | boolean | no | true |
Examples
Section titled “Examples”// 1. Add a single float column to a new table
t.float("price");
// 2. Add a float column with a default value
t.float(columnNames="rating", default="0.0");
// 3. Add multiple float columns at once
t.float("latitude,longitude");
// 4. Add a float column that does not allow NULL values
t.float(columnNames="score", allowNull=false);
// 5. Use float() within a createTable migration
t = createTable("measurements");
t.float("temperature");
t.float(columnNames="humidity,pressure", default="0.0");
t.timestamps();
t.create();