Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Ruby :: ruby loop from the last array item 
Ruby :: rails difference in minutes between 2 datetime 
Ruby :: unix timestamp to date time rails 
Ruby :: rails migration update column default value 
Ruby :: rails remove foreign key 
Ruby :: ruby filter 
Ruby :: ruby symbolize_keys 
Ruby :: rails naming conventions controller 
Ruby :: how to get ip address of client using rails 
Ruby :: ruby pluck 
Ruby :: ruby get the number of same element in array 
Ruby :: how to make a new array ruby 
Ruby :: ruby remove last element of string 
Ruby :: times ruby 
Ruby :: ruby hello 
Ruby :: rails render head: :ok 
Ruby :: params except rails 
Ruby :: ruby each 
Ruby :: helper path outside view 
Ruby :: how to remove the first element in an array ruby 
Ruby :: ruby check if hash has method before calling it 
Ruby :: ruby assign value to hash 
Ruby :: rails has_many through source 2 
Ruby :: text_field_tag transfer params rails 
Ruby :: how to require all .rb files in rails 
Ruby :: ruby regex replace capture group 
Ruby :: difference between is_a and kind_of ruby 
Ruby :: rails c add timings 
Ruby :: string uppercase ruby 
R :: loop through list in r 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =