Sha256: ca33ef48c80f79bcd1226a5ec5dc24fbd9e75c4ac343c4f460f4498b766d9c11

Contents?: true

Size: 313 Bytes

Versions: 10

Compression:

Stored size: 313 Bytes

Contents

class AddDefaultPosition < ActiveRecord::Migration
  def self.up
    change_column :pages, :position, :integer, :default => 0
    
    Page.all.each do |page|
      page.position = 0 if page.position.nil?
    end
  end
  
  def self.down
    change_column :pages, :position, :integer, :default => nil
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
radiant-drag_order-extension-0.5.0 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.8 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.7 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.6 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.4 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.2 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.4.0.beta.2 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.3.9 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.3.8 db/migrate/02_add_default_position.rb
radiant-drag_order-extension-0.3.7 db/migrate/02_add_default_position.rb