Skip to content
Browse files

Added missing docs to mysql2_adapter

  • Loading branch information...
1 parent 8f1b141 commit 0887385d8e18acda857fccc7f5c97acfec129902 @smartinez87 smartinez87 committed Apr 22, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
View
13 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -131,6 +131,7 @@ def adapter_name
ADAPTER_NAME
end
+ # Returns true, since this connection adapter supports migrations.
def supports_migrations?
true
end
@@ -139,6 +140,7 @@ def supports_primary_key?
true
end
+ # Returns true, since this connection adapter supports savepoints.
def supports_savepoints?
true
end
@@ -376,6 +378,10 @@ def create_database(name, options = {})
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 @@ def drop_table(table_name, options = {})
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 @@ def indexes(table_name, name = nil)
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 @@ def create_table(table_name, options = {})
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 @@ def show_variable(name)
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)}")

0 comments on commit 0887385

Please sign in to comment.
Something went wrong with that request. Please try again.