1
0

20240221195828_create_notification_requests.rb 804 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class CreateNotificationRequests < ActiveRecord::Migration[7.1]
  3. def change
  4. create_table :notification_requests do |t|
  5. t.references :account, null: false, foreign_key: { on_delete: :cascade }, index: false
  6. t.references :from_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }
  7. t.references :last_status, null: false, foreign_key: { to_table: :statuses, on_delete: :nullify }
  8. t.bigint :notifications_count, null: false, default: 0
  9. t.boolean :dismissed, null: false, default: false
  10. t.timestamps
  11. end
  12. add_index :notification_requests, [:account_id, :from_account_id], unique: true
  13. add_index :notification_requests, [:account_id, :id], where: 'dismissed = false', order: { id: :desc }
  14. end
  15. end