f9b309d342
A story downvote is considered a flag, just meaning the story has problems and not necessarily that the user wants to ignore it. By moving hiding out of Vote and into a new HiddenStory model, a user can now both downvote/flag and hide separately, or just one or the other.
20 lines
442 B
Ruby
20 lines
442 B
Ruby
class MoveHiddenVotesToHiddenStory < ActiveRecord::Migration
|
|
def up
|
|
create_table :hidden_stories do |t|
|
|
t.integer :user_id
|
|
t.integer :story_id
|
|
end
|
|
|
|
add_index "hidden_stories", ["user_id", "story_id"], :unique => true
|
|
|
|
Vote.where(:vote => 0).each do |v|
|
|
hs = HiddenStory.new
|
|
hs.user_id = v.user_id
|
|
hs.story_id = v.story_id
|
|
hs.save!
|
|
end
|
|
|
|
Vote.where(:vote => 0).delete_all
|
|
end
|
|
end
|