From 0887385d8e18acda857fccc7f5c97acfec129902 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Fri, 22 Apr 2011 21:30:30 -0300 Subject: Added missing docs to mysql2_adapter --- .../lib/active_record/connection_adapters/mysql2_adapter.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index 7ac72acd58..fc91814275 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -131,6 +131,7 @@ module ActiveRecord ADAPTER_NAME end + # Returns true, since this connection adapter supports migrations. def supports_migrations? true end @@ -139,6 +140,7 @@ module ActiveRecord true end + # Returns true, since this connection adapter supports savepoints. def supports_savepoints? true end @@ -376,6 +378,10 @@ module ActiveRecord end end + # Drops a MySQL database. + # + # Example: + # drop_database('sebastian_development') def drop_database(name) #:nodoc: execute "DROP DATABASE IF EXISTS `#{name}`" end @@ -406,6 +412,7 @@ module ActiveRecord super(table_name, options) end + # Returns an array of indexes for the given table. def indexes(table_name, name = nil) indexes = [] current_index = nil @@ -423,6 +430,7 @@ module ActiveRecord indexes end + # Returns an array of +Mysql2Column+ objects for the table specified by +table_name+. def columns(table_name, name = nil) sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}" columns = [] @@ -437,6 +445,10 @@ module ActiveRecord super(table_name, options.reverse_merge(:options => "ENGINE=InnoDB")) end + # Renames a table. + # + # Example: + # rename_table('octopuses', 'octopi') def rename_table(table_name, new_name) execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}" end @@ -521,6 +533,7 @@ module ActiveRecord variables.first['Value'] unless variables.empty? end + # Returns a table's primary key and belonging sequence. def pk_and_sequence_for(table) keys = [] result = execute("describe #{quote_table_name(table)}") -- cgit v1.2.3