Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix change_column to drop default with null: false #26582

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Sep 22, 2016

Currently change_column cannot drop default if null: false is
specified at the same time. This change fixes the issue.

  # 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

@rails-bot
Copy link

r? @kaspth

(@rails-bot has picked a reviewer for you, use r? to override)

@kaspth
Copy link
Contributor

kaspth commented Oct 6, 2016

We're using key? and include? haphazardly it seems. Why?

Also seems weird we sidestep options_include_default? now — surely that method was written for just this occasion?

@kamipo
Copy link
Member Author

kamipo commented Oct 8, 2016

options_include_default? was added at 6019c26 to prevent to conflict NOT NULL and DEFAULT NULL.
Using options_include_default? in add_column is correct. But using options_include_default? in change_column causes wrong side effect (cannot drop default).

@kamipo kamipo force-pushed the fix_change_column_to_drop_default_with_null_false branch from aaa5aa7 to 96bcbe0 Compare December 4, 2016 22:25
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
```
@kamipo kamipo force-pushed the fix_change_column_to_drop_default_with_null_false branch from 96bcbe0 to 7050b97 Compare January 16, 2017 13:26
@jeremy jeremy closed this in c92757f Feb 26, 2017
@kamipo kamipo deleted the fix_change_column_to_drop_default_with_null_false branch February 26, 2017 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants