Merge branch 'master' into 3898-job-state-attr
[arvados.git] / services / api / db / migrate / 20140918153705_add_state_to_job.rb
1 class AddStateToJob < ActiveRecord::Migration
2   def up
3     if !column_exists?(:jobs, :state)
4       add_column :jobs, :state, :string
5     end
6
7     Job.reset_column_information
8
9     act_as_system_user do
10       Job.all.each do |job|
11         # before_save filter will set state based on job status
12         job.save!
13       end
14     end
15   end
16
17   def down
18     if column_exists?(:jobs, :state)
19       remove_column :jobs, :state
20     end
21   end
22 end