You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then run rails db:create db:migrate which runs through
Trying to roll back that index:
rails db:rollback
results in
== 20210929121223 CreateJsonTable: reverting ==================================
-- remove_index(:json_tables, "(data->'foo')", {:using=>:gin, :name=>"index_json_tables_data_foo"})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
No indexes found on json_tables with the options provided.
bin/rails:5:in `<top (required)>'
bin/spring:10:in `block in <top (required)>'
bin/spring:7:in `tap'
bin/spring:7:in `<top (required)>'
Expected behavior
The migration can be rolled back, especially since an explicit index name has been provded.
Steps to reproduce
Open the generated migration, paste this migration into it
Then run
rails db:create db:migrate
which runs throughTrying to roll back that index:
rails db:rollback
results in
Expected behavior
The migration can be rolled back, especially since an explicit index name has been provded.
Actual behavior
As the expression is provided as
column_name
, https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L1433 does not allow the index to be removed by name.The check in this line then fails to match the index https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L1447
What reasons would there be for an index not to be removable by its name if one is explictly given in the add_index definition? I'll gladly submit a PR that will skip this check if a name has been given: https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L1446-L1448
System configuration
Rails version:
tested with current version 6.1
Ruby version:
irrelevant, but tested with 2.7.x
The text was updated successfully, but these errors were encountered: