You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20100313132032_add_issues_nested_sets_columns.rb 557B

1234567891011121314151617
  1. class AddIssuesNestedSetsColumns < ActiveRecord::Migration[4.2]
  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. Issue.update_all("parent_id = NULL, root_id = id, lft = 1, rgt = 2")
  8. end
  9. def self.down
  10. remove_column :issues, :parent_id
  11. remove_column :issues, :root_id
  12. remove_column :issues, :lft
  13. remove_column :issues, :rgt
  14. end
  15. end