4523: Simplify migration.
authorTom Clegg <tom@curoverse.com>
Mon, 5 Jan 2015 15:31:15 +0000 (10:31 -0500)
committerTom Clegg <tom@curoverse.com>
Mon, 5 Jan 2015 15:34:17 +0000 (10:34 -0500)
services/api/db/migrate/20141208185217_search_index.rb

index f11a37c51dbf7735f8477a8ad23ea5cb72f55f76..9d2616a1a8c84a11f514e70be64767c2d81c75ea 100644 (file)
@@ -24,21 +24,9 @@ class SearchIndex < ActiveRecord::Migration
     }
   end
 
-  def up
+  def change
     tables_with_searchable_columns.each do |table, columns|
-      add_index(table.to_sym, columns, name: "#{table}_search_index")
-    end
-  end
-
-  def down
-    tables_with_searchable_columns.each do |table, columns|
-      indexes = ActiveRecord::Base.connection.indexes(table)
-      search_index = indexes.select do |index|
-        index.name == "#{table}_search_index"
-      end
-      if !search_index.empty?
-        remove_index(table.to_sym, name: "#{table}_search_index")
-      end
+      add_index table.to_sym, columns, name: "#{table}_search_index"
     end
   end
 end