Skip to content

Warn when creating the same foreign key twice #5

@jdudek

Description

@jdudek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions