Skip to content

Commit

Permalink
Fix migration queries to use petition_id
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Feb 12, 2016
1 parent 1e4b3eb commit 713c4d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions db/migrate/20160210001632_update_petition_debate_states.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def up
execute <<-SQL
UPDATE petitions SET debate_state = 'debated'
WHERE debate_outcome_at IS NOT NULL
AND id IN (SELECT id FROM debate_outcomes WHERE debated = 't')
AND id IN (SELECT petition_id FROM debate_outcomes WHERE debated = 't')
SQL

execute <<-SQL
UPDATE petitions SET debate_state = 'not_debated'
WHERE debate_outcome_at IS NOT NULL
AND id IN (SELECT id FROM debate_outcomes WHERE debated = 'f')
AND id IN (SELECT petition_id FROM debate_outcomes WHERE debated = 'f')
SQL

execute <<-SQL
Expand Down Expand Up @@ -54,13 +54,13 @@ def down
execute <<-SQL
UPDATE petitions SET debate_state = 'debated'
WHERE debate_outcome_at IS NOT NULL
AND id IN (SELECT id FROM debate_outcomes WHERE debated = 't')
AND id IN (SELECT petition_id FROM debate_outcomes WHERE debated = 't')
SQL

execute <<-SQL
UPDATE petitions SET debate_state = 'none'
WHERE debate_outcome_at IS NOT NULL
AND id IN (SELECT id FROM debate_outcomes WHERE debated = 'f')
AND id IN (SELECT petition_id FROM debate_outcomes WHERE debated = 'f')
SQL

execute <<-SQL
Expand Down

0 comments on commit 713c4d7

Please sign in to comment.