Skip to content

Instantly share code, notes, and snippets.

@WaKeMaTTa
Last active April 17, 2020 08:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WaKeMaTTa/2fec97d380e479d03783fb8b95c6a311 to your computer and use it in GitHub Desktop.
Save WaKeMaTTa/2fec97d380e479d03783fb8b95c6a311 to your computer and use it in GitHub Desktop.
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