3147: PySDK tests use mock>=1.0 and easier mock side_effect.
[arvados.git] / services / api / db / migrate / 20140319160547_separate_repository_from_script_version.rb
1 class SeparateRepositoryFromScriptVersion < ActiveRecord::Migration
2   include CurrentApiClient
3
4   def fixup pt
5     c = pt.components
6     c.each do |k, v|
7       commit_ish = v["script_version"]
8       if commit_ish.andand.index(':')
9         want_repo, commit_ish = commit_ish.split(':',2)
10         v[:repository] = want_repo
11         v[:script_version] = commit_ish
12       end
13     end
14     pt.save!
15   end
16
17   def up
18     act_as_system_user do
19       PipelineTemplate.all.each do |pt|
20         fixup pt
21       end
22       PipelineInstance.all.each do |pt|
23         fixup pt
24       end
25     end
26   end
27
28   def down
29     raise ActiveRecord::IrreversibleMigration
30   end
31 end