aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2015-04-06 10:49:26 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2015-04-06 10:49:26 -0300
commit060ee2c6c94cf7050bd8be22c79e053fd602579d (patch)
treee7c13ba36776996d9cbab0266c0d7d46bd677d77
parent2c16acde0dd75e77d38b25b1254d4cffc14e81a6 (diff)
parent1a535499016ca9455a5537e1f2e720239493a598 (diff)
downloadrails-060ee2c6c94cf7050bd8be22c79e053fd602579d.tar.gz
rails-060ee2c6c94cf7050bd8be22c79e053fd602579d.tar.bz2
rails-060ee2c6c94cf7050bd8be22c79e053fd602579d.zip
Merge pull request #19667 from vngrs/drop_table_doc
drop_table method documentation for mysql and postgresql adapters [ci skip]
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb11
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb8
2 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index b7c7ff1187..51c41cd588 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -562,6 +562,17 @@ module ActiveRecord
rename_table_indexes(table_name, new_name)
end
+ # Drops a table from the database.
+ #
+ # [<tt>:force</tt>]
+ # Set to +:cascade+ to drop dependent objects as well.
+ # Defaults to false.
+ # [<tt>:if_exists</tt>]
+ # Set to +true+ to make drop table command fail safe when table does not exists.
+ # Defaults to false.
+ # [<tt>:temporary</tt>]
+ # Set to +true+ to drop temporary table.
+ # Defaults to false.
def drop_table(table_name, options = {})
execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
index c048d570e8..652ae1ed63 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -87,6 +87,14 @@ module ActiveRecord
SQL
end
+ # Drops a table from the database.
+ #
+ # [<tt>:force</tt>]
+ # Set to +:cascade+ to drop dependent objects as well.
+ # Defaults to false.
+ # [<tt>:if_exists</tt>]
+ # Set to +true+ to make drop table command fail safe when table does not exists.
+ # Defaults to false.
def drop_table(table_name, options = {})
execute "DROP TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
end