You can delete and add the foreign key in the following migration:
class ChangeForgeinKeyOnUsersTable < ActiveRecord::Migration[5.0]
def change
remove_foreign_key :users, column: :admin_id
add_foreign_key :users, :admins, column: :admin_id, on_delete: :nullify
end
end
source
share