]> git.openstreetmap.org Git - rails.git/blob - lib/migrate.rb
better SQL in putway, plus trap any 0/1-length ways that Potlatch may try to upload
[rails.git] / lib / migrate.rb
1 module ActiveRecord
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})"
8       end
9
10       alias_method :old_add_column_options!, :add_column_options!
11
12       def add_column_options!(sql, options)
13         old_add_column_options!(sql, options)
14         sql << " #{options[:options]}"
15       end
16
17       alias_method :old_options_include_default?, :options_include_default?
18
19       def options_include_default?(options)
20         old_options_include_default?(options) && !(options[:options] =~ /AUTO_INCREMENT/i)
21       end
22     end
23
24     class MysqlAdapter
25       alias_method :old_native_database_types, :native_database_types
26
27       def native_database_types
28         types = old_native_database_types
29         types[:bigint] = { :name => "bigint", :limit => 20 }
30         types
31       end
32     end
33   end
34 end
35
36 myisam_table = { :id => false, :force => true, :options => "ENGINE=MyIsam" }
37 innodb_table = { :id => false, :force => true, :options => "ENGINE=InnoDB" }