Bug #12510

[API] Don't create an index if it exists already. Will break install if we manually added it,

Added by Nico C├ęsar about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assigned To:
-
Category:
-
Target version:
Start date:
10/30/2017
Due date:
% Done:

0%

Estimated time:
Story points:
-

Description

if the index is already there, we should have some logic to avoid the upgrade of the package to fail. also in postgres we have different ways to doing depending on the version install
https://dba.stackexchange.com/questions/35616/create-index-if-it-does-not-exist

I'm referring to this:

services/api/db/migrate/20171027183824_add_index_to_containers.rb
class AddIndexToContainers < ActiveRecord::Migration
  def up
    ActiveRecord::Base.connection.execute("CREATE INDEX index_containers_on_modified_at_uuid ON containers USING btree (modified_at desc, uuid asc)")
    ActiveRecord::Base.connection.execute("CREATE INDEX index_container_requests_on_container_uuid on container_requests (container_uuid)")
  end

  def down
    ActiveRecord::Base.connection.execute("DROP INDEX IF EXISTS index_containers_on_modified_at_uuid")
    ActiveRecord::Base.connection.execute("DROP INDEX IF EXISTS index_container_requests_on_container_uuid")
  end
end

History

#1 Updated by Tom Morris about 1 year ago

  • Target version set to Arvados Future Sprints
  • Subject changed from [API] don't create an index if it's there. will brake install if we manually added it, to [API] Don't create an index if it exists already. Will break install if we manually added it,

I'm not sure that having an index with the same name guarantees that it'll match the characteristics of the index in the migration script.

Also, adding special case code to handle manual workarounds smells bad to me.

Also available in: Atom PDF