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

Version 9.0 Relation "index_taggings_on_tag_id" already exists #1071

Open
jgrant29 opened this issue Jan 5, 2022 · 2 comments
Open

Version 9.0 Relation "index_taggings_on_tag_id" already exists #1071

jgrant29 opened this issue Jan 5, 2022 · 2 comments

Comments

@jgrant29
Copy link

jgrant29 commented Jan 5, 2022

Hi all,

I am running Rails 7.0.0 and Ruby 3.0.3 with gem 'acts-as-taggable-on', '~> 9.0'. With this setup and a new rails app installation, I am receiving the errors noted below on rails db:migrate.

name@iMac alttextproject % rails db:migrate
== 20220105163513 ActsAsTaggableOnMigration: migrating ========================
-- create_table(:tags)
-> 0.0130s
-- create_table(:taggings)
-> 0.0085s
-- add_index(:taggings, :tag_id)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR: relation "index_taggings_on_tag_id" already exists
/Users/name/here/alttextproject/db/migrate/20220105163513_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:26:in `up'

Caused by:
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR: relation "index_taggings_on_tag_id" already exists
/Users/name/here/alttextproject/db/migrate/20220105163513_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:26:in `up'

Caused by:
PG::DuplicateTable: ERROR: relation "index_taggings_on_tag_id" already exists
/Users/name/here/alttextproject/db/migrate/20220105163513_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:26:in `up'

Thanks!
Justin

@jgrant29 jgrant29 changed the title Relation "index_taggings_on_tag_id" already exists Version 9.0 Relation "index_taggings_on_tag_id" already exists Jan 5, 2022
@mu-is-too-short
Copy link

I've been helping Justin try to figure this out over at:

https://stackoverflow.com/q/70599054/479863

The migration has this:

t.references :tag, foreign_key: { to_table: ActsAsTaggableOn.tags_table }
...
add_index ActsAsTaggableOn.taggings_table, :tag_id

But the t.references call creates the index that the add_index is trying to add. But t.references has been adding indexes by default for quite awhile so I'm not sure why the generated migration is broken.

Am I missing something here?

@seuros
Copy link
Collaborator

seuros commented Jan 7, 2022

I will delete all the migrations and have only 1 that is skipped by default.
It became more difficult to support those legacy migrations at every new release.

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

3 participants