This project is archived and is in readonly mode.

#26 ✓resolved
Nate Wiger

Fix for change_column :null => true in migrations

Reported by Nate Wiger | April 19th, 2008 @ 09:02 PM

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.

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.

I couldn't figure out how to test this patch within the AR test framework, as the actual table definition needs to be reverified. I have tested this on mysql and Oracle on my end and it works well.

Thanks, Nate

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments