Intro

Migrations

create table("posts") do
  add :title, :string
end

alter table("posts") do
  add :summary, :text
end

add

add column, type, options

Options

default the column’s default value. It can be a string, number, empty list, list of strings, list of numbers, or a fragment generated by fragment/1.
null when false, the column does not allow null values.
size the size of the type (for example, the number of characters). The default is no size, except for :string, which defaults to 255.
precision the precision for a numeric type. Required when :scale is specified.
scale the scale of a numeric type. Defaults to 0.

index

create index(table, columns, opts)

Options

name the name of the index. Defaults to “#{table}_#{column}_index”.
unique indicates whether the index should be unique. Defaults to false.
concurrently indicates whether the index should be created/dropped concurrently.
using configures the index type.
prefix specify an optional prefix for the index.
where specify conditions for a partial index.
include specify fields for a covering index. This is not supported by all databases. For more information on PostgreSQL support, please read the official docs.

Schemas