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

Fix generated index names for tables within schemas in PostgreSQL #45312

Merged
merged 1 commit into from
Jun 10, 2022

Conversation

fatkodima
Copy link
Member

Creation of indexes for tables with schemas generates incorrect index names:

connection.add_index "ci.my_table", "my_column"
(1.7ms)  CREATE INDEX "index_ci.my_table_on_my_column" ON "ci"."my_table" ("my_column")

And it is impossible then to delete this index:

connection.remove_index "ci.my_table", "my_column"
(0.4ms)  DROP INDEX  "ci"."index_ci"
PG::UndefinedObject: ERROR:  index "index_ci" does not exist (ActiveRecord::StatementInvalid)

And the same when explicitly specifying an index name:

connection.remove_index "ci.my_table", "my_column", name: "index_ci.my_table_on_my_column"
/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `remove_index': Index schema 'index_ci' does not match table schema 'ci' (ArgumentError)

Fixes #40821.

@byroot byroot merged commit 66225cd into rails:main Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrations with postgresql schemas name indexes incorrectly and fails to drop them
2 participants