summaryrefslogtreecommitdiffstats
path: root/db/migrate/20250423065135_create_reactions.rb
blob: 56f345e1bf1d470e7f710fc0e5512b730774f776 (plain)
1
2
3
4
5
6
7
8
9
10
11
class CreateReactions < ActiveRecord::Migration[7.2]
  def change
    create_table :reactions do |t|
      t.references :reactable, polymorphic: true, null: false
      t.references :user, null: false
      t.timestamps null: false
    end
    add_index :reactions, [:reactable_type, :reactable_id, :user_id], unique: true
    add_index :reactions, [:reactable_type, :reactable_id, :id]
  end
end