Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

rails on_delete cascade not working

// dont do a foreing_key, instead use t.references
class CreateDocumentImages < ActiveRecord::Migration[5.1]
  def change
    create_table :document_images do |t|
      t.references :document, foreign_key: { on_delete: :cascade }
      t.references :image, foreign_key: { on_delete: :cascade}
      t.timestamps
    end
  end
end
 
PREVIOUS NEXT
Tagged: #rails #cascade #working
ADD COMMENT
Topic
Name
7+8 =