From 03d235b7e396a2eab56e5c2bdd885144abd3cb4d Mon Sep 17 00:00:00 2001 From: Mauro George Date: Thu, 16 Jul 2015 19:52:34 -0300 Subject: Add missed Available transformations to migration Doc [ci skip] --- activerecord/lib/active_record/migration.rb | 65 ++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 4cfda302ea..6e530b2f27 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -106,17 +106,18 @@ module ActiveRecord # # == Available transformations # + # === Creation + # + # * create_join_table(table_1, table_2, options): Creates a join + # table having its name as the lexical order of the first two + # arguments. See + # ActiveRecord::ConnectionAdapters::SchemaStatements#create_join_table for + # details. # * create_table(name, options): 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 # is for fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create # table definition. - # * drop_table(name): Drops the table called +name+. - # * change_table(name, options): Allows to make column alterations to - # the table called +name+. It makes the table object available to a block that - # can then add/remove columns, indexes or foreign keys to it. - # * rename_table(old_name, new_name): Renames the table called +old_name+ - # to +new_name+. # * add_column(table_name, column_name, type, options): Adds a new column # to the table called +table_name+ # named +column_name+ specified to be one of the following types: @@ -127,24 +128,58 @@ module ActiveRecord # Other options include :limit and :null (e.g. # { limit: 50, null: false }) -- see # ActiveRecord::ConnectionAdapters::TableDefinition#column for details. - # * rename_column(table_name, column_name, new_column_name): Renames - # a column but keeps the type and content. - # * change_column(table_name, column_name, type, options): Changes - # the column to a different type using the same parameters as add_column. - # * remove_column(table_name, column_name, type, options): Removes the column - # named +column_name+ from the table called +table_name+. + # * add_foreign_key(from_table, to_table, options): Adds a new + # foreign key. +from_table+ is the table with the key column, +to_table+ contains + # the referenced primary key. # * add_index(table_name, column_names, options): Adds a new index # with the name of the column. Other options include # :name, :unique (e.g. # { name: 'users_name_index', unique: true }) and :order # (e.g. { order: { name: :desc } }). + # * add_reference(table_name, reference_name): Adds a new column + # +reference_name_id+ by default a integer. + # * add_timestamps(table_name, options): Adds timestamps (+created_at+ + # and +updated_at+) columns to +table_name+. + # + # === Modification + # + # * change_column(table_name, column_name, type, options): Changes + # the column to a different type using the same parameters as add_column. + # * change_column_default(table_name, column_name, default): Sets a + # default value for +column_name+ definded by +default+ on +table_name+. + # * change_column_null(table_name, column_name, null, default = nil): + # Sets or removes a +NOT NULL+ constraint on +column_name+. The +null+ flag + # indicates whether the value can be +NULL+. See + # ActiveRecord::ConnectionAdapters::SchemaStatements#change_column_null for + # details. + # * change_table(name, options): Allows to make column alterations to + # the table called +name+. It makes the table object available to a block that + # can then add/remove columns, indexes or foreign keys to it. + # * rename_column(table_name, column_name, new_column_name): Renames + # a column but keeps the type and content. + # * rename_index(table_name, old_name, new_name): Renames an index. + # * rename_table(old_name, new_name): Renames the table called +old_name+ + # to +new_name+. + # + # === Deletion + # + # * drop_table(name): Drops the table called +name+. + # * drop_join_table(table_1, table_2, options): Drops the join table + # specified by the given arguments. + # * remove_column(table_name, column_name, type, options): Removes the column + # named +column_name+ from the table called +table_name+. + # * remove_columns(table_name, *column_names): Removes the given + # columns from the table definition. + # * remove_foreign_key(from_table, options_or_to_table): Removes the + # given foreign key from the table called +table_name+. # * remove_index(table_name, column: column_names): Removes the index # specified by +column_names+. # * remove_index(table_name, name: index_name): Removes the index # specified by +index_name+. - # * add_reference(:table_name, :reference_name): Adds a new column - # +reference_name_id+ by default a integer. See - # ActiveRecord::ConnectionAdapters::SchemaStatements#add_reference for details. + # * remove_reference(table_name, ref_name, options): Removes the + # reference(s) on +table_name+ specified by +ref_name+. + # * remove_timestamps(table_name, options): Removes the timestamp + # columns (+created_at+ and +updated_at+) from the table definition. # # == Irreversible transformations # -- cgit v1.2.3