Proposal: Make change_column_null reversible

Hello everyone, I apologize if this is a duplicate; I’ve searched extensively and couldn’t find any related information.

It appears there’s no equivalent for change_column_null similar to what we have with change_column_default. Therefore, I have two proposals:

  1. Reversing a change_column_null flips its nullability

This approach is simpler to implement. By reversing a change_column_null, we apply !null and use this as the argument for change_column_null.

I think thats proposal is not viable because I have a deep feeling that people want theirs past and futures change_column_null to work as usual.

  1. Reversing a change_column_null using default_or_changes

This is more challenging to implement because I haven’t found exactly where default_or_changes is utilized for reversal. I need some guidance on where to look.

I’m not certain how useful this feature would be within Rails, but I make all my migrations reversible, and I feel the absence of this characteristic, especially since I’ve grown so accustomed to it with change_column_default, is bothersome.

Given my experience level (2 years in programming and 1 year on RoR), there might be a reason this has not been implemented, and I’m open to learning more about those reasons. However, if it’s valuable to implement this proposal, I would like to be the one to do it.

Are you sure it is not reversible? I am seeing the opposite for this statement via rails/activerecord/lib/active_record/migration/command_recorder.rb at 1007cc8c033f7713783faa02dc13f845640b464d · rails/rails · GitHub

Weird, I was having trouble with reversing change_column_null some weeks ago