Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11561 (new defect)

Opened 8 months ago

Last modified 7 months ago

[PATCH] Fix for change_column :null => true in migrations

Reported by: nwiger Assigned to: core
Priority: normal Milestone: 2.1
Component: ActiveRecord Version: edge
Severity: normal Keywords: migration change_column null
Cc:

Description

Currently, using change_column with :null => true on a formerly :null => false column does not have the proper effect. This patch fixes this issue by explicitly checking the keys for :null. I have been using this in a production setting for a while with no issues.

I don't know a good way to write tests for this, but will gladly do so if others can help offer suggestions. I have written my own migrations and run "rake db:migrate" extensively, but could not figure out how to convert these into tests w/i the AR repos.

Thanks, Nate

Attachments

schema_statements.rb.patch (1.0 kB) - added by nwiger on 04/10/08 01:20:53.
Patch to schema_statements.rb against Edge

Change History

04/10/08 01:20:53 changed by nwiger

  • attachment schema_statements.rb.patch added.

Patch to schema_statements.rb against Edge

04/10/08 01:24:28 changed by nwiger

One note: This patch can't be compressed further (outside of syntactic trickery). It's very important to not do anything unless the :null option is present. Otherwise, you can generate bad SQL which attempts to re-set a NOT NULL column to NOT NULL, and Oracle in particular will generate a fatal error.

04/10/08 20:03:49 changed by ddollar

+1

The patch looks clean, and is something that a reasonable user would expect to work.

05/06/08 06:41:12 changed by bloodroot

+1