4523: a little bit simpler script
authorRadhika Chippada <radhika@curoverse.com>
Tue, 27 Jan 2015 18:20:38 +0000 (13:20 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Tue, 27 Jan 2015 18:20:38 +0000 (13:20 -0500)
services/api/db/migrate/20150122175935_no_description_in_search_index.rb

index 01f94e530a21f69584a09bfcccd70433eb804c9b..75b946feb8b967a0034a1db486312f8da21f952b 100644 (file)
@@ -1,7 +1,11 @@
+# If the database reflects an obsolete version of the 20141208185217
+# migration (i.e., before commit:5c1db683), revert it and reapply the
+# current version. (The down-migration is the same in both versions.)
+
 require "./db/migrate/20141208185217_search_index.rb"
 
 class NoDescriptionInSearchIndex < ActiveRecord::Migration
-  def change
+  def up
     all_tables = %w{collections groups jobs pipeline_instances pipeline_templates}
     all_tables.each do |table|
       indexes = ActiveRecord::Base.connection.indexes(table)
@@ -9,16 +13,18 @@ class NoDescriptionInSearchIndex < ActiveRecord::Migration
         index.name == "#{table}_search_index"
       end
 
-      index_columns = search_index_by_name.first.andand.columns
-      has_description = index_columns.select.each do |column|
-        column == 'description'
-      end
-
-      if !has_description.empty?
-        SearchIndex.new.migrate(:down)
-        SearchIndex.new.migrate(:up)
-        break
+      if !search_index_by_name.empty?
+        index_columns = search_index_by_name.first.columns
+        has_description = index_columns.include? 'description'
+        if has_description
+          SearchIndex.new.migrate(:down)
+          SearchIndex.new.migrate(:up)
+          break
+        end
       end
     end
   end
+
+  def down
+  end
 end