[ARVADOS] created: 20c739343a381e23ff7a7f13c270cca329ac774f

git at public.curoverse.com git at public.curoverse.com
Mon Apr 21 14:27:36 EDT 2014


        at  20c739343a381e23ff7a7f13c270cca329ac774f (commit)


commit 20c739343a381e23ff7a7f13c270cca329ac774f
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Apr 21 14:28:07 2014 -0400

    Improve down-migration

diff --git a/services/api/db/migrate/20140417195429_pipeline_instance_state.rb b/services/api/db/migrate/20140417195429_pipeline_instance_state.rb
index 50230c7..6756f8a 100644
--- a/services/api/db/migrate/20140417195429_pipeline_instance_state.rb
+++ b/services/api/db/migrate/20140417195429_pipeline_instance_state.rb
@@ -34,8 +34,32 @@ class PipelineInstanceState < ActiveRecord::Migration
   end
 
   def down
-      add_column :pipeline_instances, :success, :null => true
-      add_column :pipeline_instances, :active, :default => false
-      remove_column :pipeline_instances, :state
+    add_column :pipeline_instances, :success, :boolean, :null => true
+    add_column :pipeline_instances, :active, :boolean, :default => false
+
+    act_as_system_user do
+      PipelineInstance.all.each do |pi|
+        case pi.state
+        when PipelineInstance::New, PipelineInstance::Ready
+          pi.active = false
+          pi.success = nil
+        when PipelineInstance::RunningOnServer
+          pi.active = true
+          pi.success = nil
+        when PipelineInstance::RunningOnClient
+          pi.active = false
+          pi.success = nil
+        when PipelineInstance::Failed
+          pi.active = false
+          pi.success = false
+        when PipelineInstance::Complete
+          pi.active = false
+          pi.success = true
+        end
+        pi.save!
+      end
+    end
+
+    remove_column :pipeline_instances, :state
   end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list