From 906ff07e71eade42ac3856591faea5ffe857b44f Mon Sep 17 00:00:00 2001 From: "travis.h.oneill@gmail.com" Date: Wed, 17 Aug 2016 17:21:54 -0700 Subject: Added nil case handling to allow rollback migration in case of invalid column type /activerecord/lib/active_record/connection_adapters /abstract/schema_definitions.rb:306 type = type.to_sym Changed to the following to handle nil case: type = type.to_sym if type Added regression test for this case: /activerecord/test/cases/migration_test.rb:554 if current_adapter?(:SQLite3Adapter) def test_allows_sqlite3_rollback_on_invalid_column_type Person.connection.create_table :something, force: true do |t| t.column :number, :integer t.column :name, :string t.column :foo, :bar end assert Person.connection.column_exists?(:something, :foo) assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar } assert !Person.connection.column_exists?(:something, :foo) assert Person.connection.column_exists?(:something, :name) assert Person.connection.column_exists?(:something, :number) ensure Person.connection.drop_table :something, if_exists: true end end --- .../active_record/connection_adapters/abstract/schema_statements.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index afa0860707..45d782e45e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1047,7 +1047,8 @@ module ActiveRecord end def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: - if native = native_database_types[type.to_sym] + type = type.to_sym if type + if native = native_database_types[type] column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup if type == :decimal # ignore limit, use precision and scale -- cgit v1.2.3