diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-09-22 21:22:14 +0900 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-26 00:23:04 -0700 |
commit | c92757fb68f5a281be0f2ea67e369672e9c4ec6d (patch) | |
tree | 0578c7ffc24acfc43a3161dec82722cbadb51574 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | |
parent | 31d27d5301c79c351c69b91d64e32a64b0f2b0fb (diff) | |
download | rails-c92757fb68f5a281be0f2ea67e369672e9c4ec6d.tar.gz rails-c92757fb68f5a281be0f2ea67e369672e9c4ec6d.tar.bz2 rails-c92757fb68f5a281be0f2ea67e369672e9c4ec6d.zip |
Fix `change_column` to drop default with `null: false`
Currently `change_column` cannot drop default if `null: false` is
specified at the same time. This change fixes the issue.
```ruby
# cannot drop default
change_column "tests", "contributor", :boolean, default: nil, null: false
# we need the following workaround currently
change_column "tests", "contributor", :boolean, null: false
change_column "tests", "contributor", :boolean, default: nil
```
Closes #26582
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index a61d920a73..f91547d148 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -489,7 +489,7 @@ module ActiveRecord end execute sql - change_column_default(table_name, column_name, options[:default]) if options_include_default?(options) + change_column_default(table_name, column_name, options[:default]) if options.key?(:default) change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null) change_column_comment(table_name, column_name, options[:comment]) if options.key?(:comment) end |