14285: Merge branch 'master' into 14285-keep-balance-metrics
[arvados.git] / services / api / db / migrate / 20140918153705_add_state_to_job.rb
index 7b595a36cdf2f331d7cdabcec5d94d2e8fde603a..77310d3ac95ac315a06134f48834fea267a43313 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class AddStateToJob < ActiveRecord::Migration
   include CurrentApiClient
 
@@ -9,6 +13,8 @@ class AddStateToJob < ActiveRecord::Migration
       Job.update_all({state: 'Failed'}, ['state is null and success = ?', false])
       Job.update_all({state: 'Complete'}, ['state is null and success = ?', true])
       Job.update_all({state: 'Running'}, ['state is null and running = ?', true])
+      # Locked/started, but not Running/Failed/Complete? Let's assume it failed.
+      Job.update_all({state: 'Failed'}, ['state is null and (is_locked_by_uuid is not null or started_at is not null)'])
       Job.update_all({state: 'Queued'}, ['state is null'])
     end
   end