From 877007eb8d7bf4022025ec4f817ec1d357c75526 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 3 Aug 2012 23:16:56 +0400 Subject: [PATCH] [issue #590] Added missed migration --- ...1_add_save_to_repository_to_build_lists.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb diff --git a/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb b/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb new file mode 100644 index 000000000..f71eb1d01 --- /dev/null +++ b/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb @@ -0,0 +1,24 @@ +class AddSaveToRepositoryToBuildLists < ActiveRecord::Migration + def self.up + add_column :build_lists, :save_to_repository_id, :integer + + BuildList.scoped.find_in_batches do |batch| + batch.each do |bl| + begin + project = bl.project + platform = bl.save_to_platform + + rep = (project.repositories.map(&:id) & platform.repositories.map(&:id)).first + bl.save_to_repository_id = rep + bl.save + rescue + false + end + end + end + end + + def self.down + remove_column :build_lists, :save_to_repository_id + end +end