class CreateGekanatorQuestionExamples < ActiveRecord::Migration[8.0]
  def change
    create_table :gekanator_question_examples do |t|
      t.references :gekanator_question, null: false, foreign_key: true
      t.references :post, null: false, foreign_key: true
      t.references :user, null: false, foreign_key: true
      t.references :gekanator_game, null: true, foreign_key: true
      t.string :answer, null: false
      t.string :source, null: false, default: 'post_game_extra'
      t.float :weight, null: false, default: 1.0
      t.timestamps
    end

    add_index :gekanator_question_examples,
              [:gekanator_question_id, :post_id, :user_id],
              unique: true,
              name: 'idx_gekanator_question_examples_on_question_post_user'
  end
end
