To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / db / migrate / 20100313132032_add_issues_nested_sets_columns.rb @ 442:753f1380d6bc

History | View | Annotate | Download (556 Bytes)

1
class AddIssuesNestedSetsColumns < ActiveRecord::Migration
2
  def self.up
3
    add_column :issues, :parent_id, :integer, :default => nil
4
    add_column :issues, :root_id, :integer, :default => nil
5
    add_column :issues, :lft, :integer, :default => nil
6
    add_column :issues, :rgt, :integer, :default => nil
7
    
8
    Issue.update_all("parent_id = NULL, root_id = id, lft = 1, rgt = 2")
9
  end
10

    
11
  def self.down
12
    remove_column :issues, :parent_id
13
    remove_column :issues, :root_id
14
    remove_column :issues, :lft
15
    remove_column :issues, :rgt
16
  end
17
end