discourse/plugins/discourse-post-voting/db/migrate/20211020062413_create_question_answer_votes.rb
2025-07-15 16:38:05 +02:00

20 lines
549 B
Ruby

# frozen_string_literal: true
class CreateQuestionAnswerVotes < ActiveRecord::Migration[6.1]
def up
create_table :question_answer_votes do |t|
t.integer :post_id, null: false
t.integer :user_id, null: false
t.datetime :created_at, null: false
end
add_index :question_answer_votes, %i[post_id user_id], unique: true
add_column :posts, :qa_vote_count, :integer, default: 0, null: true
end
def down
drop_table :question_answer_votes
remove_index :question_answer_votes, %i[post_id user_id]
end
end