Project

General

Profile

Actions

Bug #12510

open

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

Added by Nico César over 6 years ago. Updated 4 months ago.

Status:
New
Priority:
Normal
Assigned To:
-
Category:
-
Target version:
Story points:
-
Release:
Release relationship:
Auto

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

Actions

Also available in: Atom PDF