Skip to content

Instantly share code, notes, and snippets.

@RomanTurner
Created September 10, 2021 21:05
Show Gist options
  • Save RomanTurner/a3e331bfd78d7b31a77b5c2b369c3d02 to your computer and use it in GitHub Desktop.
Save RomanTurner/a3e331bfd78d7b31a77b5c2b369c3d02 to your computer and use it in GitHub Desktop.
A list of types you can use in the Rails migration dsl
def change
create_table :table do |t|
t.column # adds an ordinary column. Ex: t.column(:name, :string)
t.index # adds a new index.
t.timestamps
t.change # changes the column definition. Ex: t.change(:name, :string, :limit => 80)
t.change_default # changes the column default value.
t.rename # changes the name of the column.
t.references
t.belongs_to #alias for references
t.string
t.text
t.integer
t.float
t.decimal
t.datetime
t.text
t.timestamp
t.time
t.date
t.binary
t.boolean
t.remove
t.remove_references
t.remove_belongs_to
t.remove_index
t.remove_timestamps
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment