Ticket #3735: migrations_add_primary_key_column.diff
| File migrations_add_primary_key_column.diff, 1.6 kB (added by jramirez, 2 years ago) |
|---|
-
activerecord/test/active_schema_test_mysql.rb
old new 24 24 assert_equal "ALTER TABLE people ADD `key` varchar(32)", add_column(:people, :key, :string, :limit => 32) 25 25 end 26 26 27 def test_add_column_with_primary_key_type 28 assert_equal "ALTER TABLE people ADD `new_key` int(11) DEFAULT NULL auto_increment PRIMARY KEY", add_column(:people, :new_key, :primary_key) 29 end 30 27 31 private 28 32 def method_missing(method_symbol, *arguments) 29 33 ActiveRecord::Base.connection.send(method_symbol, *arguments) -
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
old new 254 254 255 255 def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: 256 256 native = native_database_types[type] 257 column_type_sql = native[:name] 257 #when using :primary_key type, we will not get a hash, but a string. We return it directly 258 return native if native.class == String 259 column_type_sql = native[:name] 258 260 if type == :decimal # ignore limit, use precison and scale 259 261 precision ||= native[:precision] 260 262 scale ||= native[:scale]