Last active
April 17, 2020 08:13
-
-
Save WaKeMaTTa/2fec97d380e479d03783fb8b95c6a311 to your computer and use it in GitHub Desktop.
Rails migration with foreign key cascade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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