Skip to content

Renaming a table removes and re-adds FK constraints with no option to disable #4

Description

@leejarvis

Hi,

My app has a very large table (lets call it articles) and another slightly smaller table called comments. I added a migration to rename the comments table to messages and was very surprised to see our app blow up when the migration started hanging. After some research it appeared that a constraint was being removed and re-added here. I understand the constraint is being removed and re-added because it cannot be renamed in all cases, but I would expect there to be some way to disable this. Since the following migration:

def change
  rename_table :comments, :messages
end

Appears to have no side affects. Changing the name of the constraints isn't a necessity so it would be nice to turn this off.

Also, in PostgreSQL versions later than 9.2, it's possible to rename a constraint:

alter table messages rename constraint fk_comments_article_id to fk_messages_article_id

Is it possible to have a configuration option to enable constraint renaming or at the very least, disable removing and re-creating these constraints?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions