Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] : Can we do the validate foreign key in the same migration where we add it #84

Closed
bheemreddy181-zz opened this issue Jul 22, 2019 · 2 comments

Comments

@bheemreddy181-zz
Copy link

Can we have the validate foreign key validation in the same migration for addition

like

class AddForeignKeyOnUsers < ActiveRecord::Migration[5.2]
  def change
    add_foreign_key :users, :orders, validate: false
    validate_foreign_key :users, :orders
  end
end

do these should be in separate migrations so that they happen on a separate transaction

@ankane
Copy link
Owner

ankane commented Jul 23, 2019

They should be in separate migrations so they happen in separate transactions.

@ankane ankane closed this as completed Jul 23, 2019
@MaicolBen
Copy link

Is this for existing fields? I don't see it will lock the table if the field is new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants