Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fix for change_column :null => true in migrations

#26

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

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Nate Wiger
    Nate Wiger

    +1 from ddollar

    Just copying a +1 from old Rails Trac

    April 19th, 2008 @ 09:02 PM

  2. John Barnette
    John Barnette
    • Title changed from [PATCH] Fix for change_column :null => true in migrations to Fix for change_column :null => true in migrations

    April 22nd, 2008 @ 08:24 AM

  3. Repository
    Repository
    • State changed from new to resolved

    (from [10ef65a3b054270ed3d458ec8eb7c2b9a3e638f7]) Fixed that change_column should be able to use :null => true on a field that formerly had false [Nate Wiger] [#26 state:resolved]

    http://github.com/rails/rails/co...

    April 29th, 2008 @ 10:53 PM