Sha256: 232a451d0cd7673b0bfdb8cf81cc5c8965563416ca23fdc9d2362d7716d98a7f

Contents?: true

Size: 601 Bytes

Versions: 7

Compression:

Stored size: 601 Bytes

Contents

class AddSubtasks < ActiveRecord::Migration
  def self.up
    add_column :tasks, :parent_id, :integer, :references => :tasks
    add_column :backlogs, :enable_subtasks, :boolean, :null => false, :default => false
  end

  def self.down
    Task.find(:all).each do |task|
      task.period_id = task.root_task.period_id
      task.save!
    end
    remove_column :tasks, :parent_id
    remove_column :backlogs, :enable_subtasks
  end
end

class Task < ActiveRecord::Base
  acts_as_tree :order => 'position'
  
  def root_task
    if parent
      parent.root_task
    else
      self
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
backlog-0.0.0 db/migrate/009_add_subtasks.rb
backlog-0.0.1 db/migrate/009_add_subtasks.rb
backlog-0.0.2 db/migrate/009_add_subtasks.rb
backlog-0.0.4 db/migrate/009_add_subtasks.rb
backlog-0.0.5 db/migrate/009_add_subtasks.rb
backlog-0.1.0 db/migrate/009_add_subtasks.rb
backlog-0.1.1 db/migrate/009_add_subtasks.rb