Class: ExtendPages

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/templates/db/migrate/20090625125735_extend_pages.rb

Class Method Summary collapse

Class Method Details

.downObject



13
14
15
16
17
18
19
20
# File 'lib/generators/templates/db/migrate/20090625125735_extend_pages.rb', line 13

def self.down
  change_table :pages do |t|
    t.remove :show_in_header
    t.remove :show_in_footer
    t.remove :foreign_link
    t.remove :position
  end
end

.upObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/generators/templates/db/migrate/20090625125735_extend_pages.rb', line 2

def self.up
  change_table :pages do |t|
    t.boolean :show_in_header, :default => false, :null => false
    t.boolean :show_in_footer, :default => false, :null => false
    t.string  :foreign_link
    t.integer :position, :default => 1, :null => false
    Page.all(:order => "updated_at ASC").each_with_index{|page,x| page.update_attribute(:position, x+1)}

  end
end