Skip to content

add_enum_value with "if not exists" #23

@futuretap

Description

@futuretap

When I rollback and migrate again a migration that adds an enum value, I get an error:

ActiveRecord::StatementInvalid: PG::DuplicateObject: ERROR: enum label "unknown" already exists

This is my migration:

def up
  add_enum_value :review_image_category, 'unknown'
end
  
def down
  # there's no drop_enum_value
end

While Postgres indeed doesn't support ALTER TYPE DROP VALUE it does support ALTER TYPE ADD VALUE IF NOT EXISTS. Is this somehow accessible from the gem? An :if_not_exists parameter would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions