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

Warn when creating the same foreign key twice #5

Open
jdudek opened this issue Jul 6, 2011 · 0 comments
Open

Warn when creating the same foreign key twice #5

jdudek opened this issue Jul 6, 2011 · 0 comments

Comments

@jdudek
Copy link

jdudek commented Jul 6, 2011

Imagine the following scenario (using MySQL):

  • generate automatic_foreign_key:migration in existing project
  • run it and see it fail somewhere in the middle
  • fix the migration, see it run successfully

Now you have created twice all the foreign keys that were before the failing one. As a result, you'll have some garbage in the database and db/schema.rb.

Although the root cause of the problem is lack of transactional DDL in MySQL, this behaviour is slightly different than usual errors in migrations. E.g when you fail in the middle of adding columns, run it again, then you cannot add the earlier columns twice and migration will fail earlier.

The proposed solution is to output warnings when creating foreign key same as one that already exists.

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

1 participant