class Rotor::TableBuilder
The columns of a table that create_table (or a reversible
drop_table) declares: the block's t.
/home/runner/work/rotor/rotor/src/migration.qz:107
Class methods
def self.new(table: String) -> Rotor::TableBuilder
(For table.)
Methods
def columns -> Array[Rotor::ColumnDef]
The columns declared so far.
def indexes -> Array[Rotor::IndexDef]
The indexes declared so far.
def column(name: Symbol, type: Type[Int], *, null: Bool = …, default: Int | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
An Int column (bigint). null: admits NULL, default: is its
default, primary: makes it the primary key (no id is added then).
def column(name: Symbol, type: Type[Float], *, null: Bool = …, default: Float | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
A Float column (double precision).
def column(name: Symbol, type: Type[String], *, null: Bool = …, default: String | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
A String column (text).
def column(name: Symbol, type: Type[Bool], *, null: Bool = …, default: Bool | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
A Bool column (boolean).
def column(name: Symbol, type: Type[Time], *, null: Bool = …, default: Rotor::SQL::Raw? = …, primary: Bool = …) -> Void
A Time column (timestamptz): its default only as SQL
(Rotor::SQL.raw("now()")).
def column(name: Symbol, type: Type[Bytes], *, null: Bool = …, default: Bytes | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
A Bytes column (bytea).
def column(name: Symbol, *, sql: String, null: Bool = …, default: String | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void
A column of an SQL type rotor has no class for (sql: "numeric(12,2)"), which a model reads as a String, as pg gives it.
def timestamps -> Void
created_at and updated_at, timestamptz and not NULL, which
Rotor::Repo sets.
def references(name: Symbol, *, to_table: Symbol? = …, on_delete: Symbol? = …, null: Bool = …, index: Bool = …) -> Void
<name>_id, a bigint that references to_table (by default
name plural: users) by its id, with ON DELETE on_delete, and
an index unless index: false.
def index(columns: Array[Symbol], *, unique: Bool = …, name: Symbol? = …, where: String? = …) -> Void
An index of the table on columns.