2 module ConnectionAdapters
3 module SchemaStatements
4 def add_primary_key(table_name, column_name, options = {})
5 column_names = Array(column_name)
6 quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ")
7 execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{quoted_column_names})"
10 alias_method :old_add_column_options!, :add_column_options!
12 def add_column_options!(sql, options)
13 old_add_column_options!(sql, options)
14 sql << " #{options[:options]}"
17 alias_method :old_options_include_default?, :options_include_default?
19 def options_include_default?(options)
20 old_options_include_default?(options) && !(options[:options] =~ /AUTO_INCREMENT/i)
25 alias_method :old_native_database_types, :native_database_types
27 def native_database_types
28 types = old_native_database_types
29 types[:bigint] = { :name => "bigint", :limit => 20 }
36 myisam_table = { :id => false, :force => true, :options => "ENGINE=MyIsam" }
37 innodb_table = { :id => false, :force => true, :options => "ENGINE=InnoDB" }