1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class PipelineInstanceState < ActiveRecord::Migration[4.2]
6 include CurrentApiClient
9 add_column :pipeline_instances, :state, :string
10 add_column :pipeline_instances, :components_summary, :text
12 PipelineInstance.reset_column_information
15 PipelineInstance.all.each do |pi|
16 pi.state = PipelineInstance::New
18 if !pi.attribute_present? :success # success is nil
19 if pi[:active] == true
20 pi.state = PipelineInstance::RunningOnServer
22 if pi.components_look_ready?
23 pi.state = PipelineInstance::Ready
25 pi.state = PipelineInstance::New
28 elsif pi[:success] == true
29 pi.state = PipelineInstance::Complete
31 pi.state = PipelineInstance::Failed
38 # We want to perform addition of state, and removal of active and success in two phases. Hence comment these statements out.
40 if column_exists?(:pipeline_instances, :active)
41 remove_column :pipeline_instances, :active
44 if column_exists?(:pipeline_instances, :success)
45 remove_column :pipeline_instances, :success
51 # We want to perform addition of state, and removal of active and success in two phases. Hence comment these statements out.
53 add_column :pipeline_instances, :success, :boolean, :null => true
54 add_column :pipeline_instances, :active, :boolean, :default => false
57 PipelineInstance.all.each do |pi|
59 when PipelineInstance::New, PipelineInstance::Ready
62 when PipelineInstance::RunningOnServer
65 when PipelineInstance::RunningOnClient
68 when PipelineInstance::Failed
71 when PipelineInstance::Complete
80 if column_exists?(:pipeline_instances, :components_summary)
81 remove_column :pipeline_instances, :components_summary
84 if column_exists?(:pipeline_instances, :state)
85 remove_column :pipeline_instances, :state