view .svn/pristine/ac/ac50a6b39635018231c646605bc398d2a48c5f14.svn-base @ 1539:22d57b0e0a77 live

OK, this script works now, but it should be using the API
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 21 May 2015 17:31:06 +0100
parents dffacf8a6908
children
line wrap: on
line source
class RemoveCustomFieldsMinMaxLengthDefaultValues < ActiveRecord::Migration
  def up
    change_column :custom_fields, :min_length, :int, :default => nil, :null => true
    change_column :custom_fields, :max_length, :int, :default => nil, :null => true
    CustomField.where(:min_length => 0).update_all(:min_length => nil)
    CustomField.where(:max_length => 0).update_all(:max_length => nil)
  end

  def self.down
    CustomField.where(:min_length => nil).update_all(:min_length => 0)
    CustomField.where(:max_length => nil).update_all(:max_length => 0)
    change_column :custom_fields, :min_length, :int, :default => 0, :null => false
    change_column :custom_fields, :max_length, :int, :default => 0, :null => false
  end
end