20180831171112_create_bookmarks.rb 520 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class CreateBookmarks < ActiveRecord::Migration[5.2]
  3. def change
  4. create_table :bookmarks do |t|
  5. t.references :account, null: false
  6. t.references :status, null: false
  7. t.timestamps
  8. end
  9. safety_assured do
  10. add_foreign_key :bookmarks, :accounts, column: :account_id, on_delete: :cascade
  11. add_foreign_key :bookmarks, :statuses, column: :status_id, on_delete: :cascade
  12. end
  13. add_index :bookmarks, [:account_id, :status_id], unique: true
  14. end
  15. end