Migrator
time()
Signature
Section titled “Signature”time() — returns any
Available in: tabledefinition
Category: Table Definition Functions
Description
Section titled “Description”adds time columns to table definition
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
columnNames | string | no | — | |
default | any | no | — | |
allowNull | boolean | no | — |
Examples
Section titled “Examples”// 1. Add a single time column to a new table
t = createTable(name='schedules');
t.string(columnNames='title', limit=255, allowNull=false);
t.time(columnNames='startTime', allowNull=false);
t.timestamps();
t.create();
// 2. Add multiple time columns at once
t = createTable(name='shifts');
t.string(columnNames='employeeName', limit=100, allowNull=false);
t.time(columnNames='clockIn,clockOut', allowNull=false);
t.timestamps();
t.create();
// 3. Add a nullable time column with a default to an existing table
t = changeTable(name='stores');
t.time(columnNames='openTime', allowNull=true, default='09:00:00');
t.change();