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.)

/home/runner/work/rotor/rotor/src/migration.qz:113

Methods

def columns -> Array[Rotor::ColumnDef]

The columns declared so far.

/home/runner/work/rotor/rotor/src/migration.qz:117

def indexes -> Array[Rotor::IndexDef]

The indexes declared so far.

/home/runner/work/rotor/rotor/src/migration.qz:120

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).

/home/runner/work/rotor/rotor/src/migration.qz:124

def column(name: Symbol, type: Type[Float], *, null: Bool = …, default: Float | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void

A Float column (double precision).

/home/runner/work/rotor/rotor/src/migration.qz:129

def column(name: Symbol, type: Type[String], *, null: Bool = …, default: String | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void

A String column (text).

/home/runner/work/rotor/rotor/src/migration.qz:134

def column(name: Symbol, type: Type[Bool], *, null: Bool = …, default: Bool | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void

A Bool column (boolean).

/home/runner/work/rotor/rotor/src/migration.qz:139

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()")).

/home/runner/work/rotor/rotor/src/migration.qz:145

def column(name: Symbol, type: Type[Bytes], *, null: Bool = …, default: Bytes | Rotor::SQL::Raw | Nil = …, primary: Bool = …) -> Void

A Bytes column (bytea).

/home/runner/work/rotor/rotor/src/migration.qz:150

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.

/home/runner/work/rotor/rotor/src/migration.qz:156

def timestamps -> Void

created_at and updated_at, timestamptz and not NULL, which Rotor::Repo sets.

/home/runner/work/rotor/rotor/src/migration.qz:162

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.

/home/runner/work/rotor/rotor/src/migration.qz:170

def index(columns: Array[Symbol], *, unique: Bool = …, name: Symbol? = …, where: String? = …) -> Void

An index of the table on columns.

/home/runner/work/rotor/rotor/src/migration.qz:177