mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 12:58:48 +01:00
Added migration to fix incorrectly hidden todos
Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
parent
a634206e5f
commit
6bc68bcf6c
1 changed files with 18 additions and 0 deletions
18
db/migrate/046_fix_incorrectly_hidden_todos.rb
Normal file
18
db/migrate/046_fix_incorrectly_hidden_todos.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class FixIncorrectlyHiddenTodos < ActiveRecord::Migration
|
||||
def self.up
|
||||
hidden_todos_without_project =
|
||||
Todo.find(:all, :conditions => "state='project_hidden' AND project_id IS NULL")
|
||||
|
||||
active_projects = Project.find(:all, :conditions => "state='active'")
|
||||
hidden_todos_in_active_projects =
|
||||
Todo.find(:all, :conditions => ["state='project_hidden' AND project_id IN (?)", active_projects])
|
||||
|
||||
todos_to_fix = hidden_todos_without_project + hidden_todos_in_active_projects
|
||||
todos_to_fix.each do |todo|
|
||||
todo.update_attribute :state, 'active'
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue