Skip to content

db:setup fails with ActiveRecord::StatementInvalid: PG::DuplicateObject #22

@emersonthis

Description

@emersonthis

Describe the bug
After adding a couple migrations that use add_enum I can no longer run rake db:setup without the following error:

$ bundle exec rake db:setup
Database 'myapp_dev' already exists
Database 'myapp_test' already exists
rake aborted!
ActiveRecord::StatementInvalid: PG::DuplicateObject: ERROR:  type "question_answer_length" already exists
/Users/emerson/Code/myapp/db/schema.rb:18:in `block in <main>'
/Users/emerson/Code/myapp/db/schema.rb:13:in `<main>'
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'

Caused by:
PG::DuplicateObject: ERROR:  type "question_answer_length" already exists
/Users/emerson/Code/myapp/db/schema.rb:18:in `block in <main>'
/Users/emerson/Code/myapp/db/schema.rb:13:in `<main>'
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)

To Reproduce
Steps to reproduce the behavior:

  1. Added gem 'activerecord-postgres_enum' to Gemfile
  2. $ bundle install
  3. Create a couple migrations that use add_enum
  4. Run $ bundle exec rake db:setup

Expected behavior
Command runs without error.

Context (please complete the following information):

  • OS: MacOS
  • Version 10.15.3

Additional context
Ruby version 2.6.3p62
PostgreSQL version 12

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions