1
0

20180831171112_create_bookmarks.rb 489 B

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