module ActiveRecord::ModelSpaces::MySQLTableSchemaCopier

Public Instance Methods

change_table_name(from_table_name, to_table_name, schema) click to toggle source
# File lib/active_record/model_spaces/table_manager.rb, line 84
def change_table_name(from_table_name, to_table_name, schema)
  schema.gsub(/CREATE TABLE `#{from_table_name}`/, "CREATE TABLE `#{to_table_name}`")
end
copy_table_schema(connection, from_table_name, to_table_name) click to toggle source
# File lib/active_record/model_spaces/table_manager.rb, line 74
def copy_table_schema(connection, from_table_name, to_table_name)
  from_table_schema = table_schema(connection, from_table_name)
  to_table_schema = change_table_name(from_table_name, to_table_name, from_table_schema)
  connection.execute(to_table_schema)
end
table_schema(connection, table_name) click to toggle source
# File lib/active_record/model_spaces/table_manager.rb, line 80
def table_schema(connection, table_name)
  connection.select_rows("SHOW CREATE TABLE `#{table_name}`").last.last
end