Skip to content

Instantly share code, notes, and snippets.

@WaKeMaTTa
Last active Apr 17, 2020
Embed
What would you like to do?
Rails migration with foreign key cascade
class UpdateForeignKey < ActiveRecord::Migration[5.0]
def change
add_reference :posts, :users, index: true, foreign_key: { on_delete: :cascade }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment