E
E
eldar_web2018-07-27 12:08:44
Ruby on Rails
eldar_web, 2018-07-27 12:08:44

How to remove a unique index in Ruby on Rails?

I delete like this:

remove_index :price_crosses, name: :price_crosses_oem_make_name_cross_oem_cross_make_name_key

And he writes:
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DependentObjectsStillExist: ERROR: cannot drop index price_crosses_oem_make_name_cross_oem_cross_make_name_key because constraint price_crosses_oem_make_name_cross_oem_cross_make_name_key on table price_crosses requires it
HINT: You can drop constraint price_crosses_oem_make_name_cross_o_key
: DROP INDEX "price_crosses_oem_make_name_cross_oem_cross_make_name_key"
/home/woto/work/eldar/allzap/apps/www/db/migrate/9011090606662959_remove_index_from_price_crosses.rb:3:in `change'
script/rails:6:in `require'
script/rails:6 :in `'
Caused by:
ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR: cannot drop index price_crosses_oem_make_name_cross_oem_cross_make_name_key because constraint price_crosses_oem_make_name_cross_oem_cross_make_name_key on table price_crosses requires it
HINT: You can drop constraint price_crosses_oem_make_name_cross_oem_key on table_crosses instead
: DROP INDEX "price_crosses_oem_make_name_cross_oem_cross_make_name_key"
/home/woto/work/eldar/allzap/apps/www/db/migrate/9011090606662959_remove_index_from_price_crosses.rb:3:in `change'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2018-07-27
@notwrite

It says right here what to do.

HINT: You can drop constraint price_crosses_oem_make_name_cross_oem_cross_make_name_key on table price_crosses instead.
: DROP INDEX "price_crosses_oem_make_name_cross_oem_cross_make_name_key

D
dan lar, 2018-07-27
@vortx

remove_index :accounts, column: [:branch_id, :party_id]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question