aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-30 18:48:22 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-30 18:48:22 -0500
commitc5647a08b4a6ece80379306d9f148608e2597d83 (patch)
treed77aee9e774254d1168fe4862b1194c7a9c1f66b /activerecord/lib/active_record/migration.rb
parentce7d1070af5682b601fa14d53f63de4c3fd19e9e (diff)
downloadrails-c5647a08b4a6ece80379306d9f148608e2597d83.tar.gz
rails-c5647a08b4a6ece80379306d9f148608e2597d83.tar.bz2
rails-c5647a08b4a6ece80379306d9f148608e2597d83.zip
add change_table transformation to Migration docsĀ [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r--activerecord/lib/active_record/migration.rb35
1 files changed, 19 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index c1d57855a9..ce9c2fbac0 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -50,7 +50,7 @@ module ActiveRecord
#
# class AddSsl < ActiveRecord::Migration
# def up
- # add_column :accounts, :ssl_enabled, :boolean, :default => true
+ # add_column :accounts, :ssl_enabled, :boolean, default: true
# end
#
# def down
@@ -62,7 +62,7 @@ module ActiveRecord
# if you're backing out of the migration. It shows how all migrations have
# two methods +up+ and +down+ that describes the transformations
# required to implement or remove the migration. These methods can consist
- # of both the migration specific methods like add_column and remove_column,
+ # of both the migration specific methods like +add_column+ and +remove_column+,
# but may also contain regular Ruby code for generating data needed for the
# transformations.
#
@@ -70,7 +70,7 @@ module ActiveRecord
#
# class AddSystemSettings < ActiveRecord::Migration
# def up
- # create_table :system_settings do |t|
+ # create_table system_settings: do |t|
# t.string :name
# t.string :label
# t.text :value
@@ -78,9 +78,9 @@ module ActiveRecord
# t.integer :position
# end
#
- # SystemSetting.create :name => "notice",
- # :label => "Use notice?",
- # :value => 1
+ # SystemSetting.create name: 'notice',
+ # label: 'Use notice?',
+ # value: 1
# end
#
# def down
@@ -88,19 +88,22 @@ module ActiveRecord
# end
# end
#
- # This migration first adds the system_settings table, then creates the very
+ # This migration first adds the +system_settings+ table, then creates the very
# first row in it using the Active Record model that relies on the table. It
- # also uses the more advanced create_table syntax where you can specify a
+ # also uses the more advanced +create_table+ syntax where you can specify a
# complete table schema in one block call.
#
# == Available transformations
#
- # * <tt>create_table(name, options)</tt> Creates a table called +name+ and
+ # * <tt>create_table(name, options)</tt>: Creates a table called +name+ and
# makes the table object available to a block that can then add columns to it,
- # following the same format as add_column. See example above. The options hash
+ # following the same format as +add_column+. See example above. The options hash
# is for fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create
# table definition.
# * <tt>drop_table(name)</tt>: Drops the table called +name+.
+ # * <tt>change_table(name, options)</tt>: Allows to make column alterations to
+ # the table called +name+. It makes the table object availabe to a block that
+ # can then add/remove columns, indexes or foreign keys to it.
# * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+
# to +new_name+.
# * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column
@@ -109,9 +112,9 @@ module ActiveRecord
# <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>,
# <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>,
# <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be
- # specified by passing an +options+ hash like <tt>{ :default => 11 }</tt>.
+ # specified by passing an +options+ hash like <tt>{ default: 11 }</tt>.
# Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g.
- # <tt>{ :limit => 50, :null => false }</tt>) -- see
+ # <tt>{ limit: 50, null: false }</tt>) -- see
# ActiveRecord::ConnectionAdapters::TableDefinition#column for details.
# * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames
# a column but keeps the type and content.
@@ -122,11 +125,11 @@ module ActiveRecord
# * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index
# with the name of the column. Other options include
# <tt>:name</tt>, <tt>:unique</tt> (e.g.
- # <tt>{ :name => "users_name_index", :unique => true }</tt>) and <tt>:order</tt>
- # (e.g. { :order => {:name => :desc} }</tt>).
- # * <tt>remove_index(table_name, :column => column_name)</tt>: Removes the index
+ # <tt>{ name: 'users_name_index', unique: true }</tt>) and <tt>:order</tt>
+ # (e.g. { order: { name: :desc } }</tt>).
+ # * <tt>remove_index(table_name, column: column_name)</tt>: Removes the index
# specified by +column_name+.
- # * <tt>remove_index(table_name, :name => index_name)</tt>: Removes the index
+ # * <tt>remove_index(table_name, name: index_name)</tt>: Removes the index
# specified by +index_name+.
#
# == Irreversible transformations