From f29b38d48edd8a83b6cf85c592b635a836e995f5 Mon Sep 17 00:00:00 2001 From: Danilo Resende Date: Sun, 5 May 2013 12:38:59 -0300 Subject: [PATCH] add task to migrate a single php project --- lib/migrate/projects.rb | 12 ++++++++---- lib/tasks/migrate.rake | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/migrate/projects.rb b/lib/migrate/projects.rb index 792e976..27c9c32 100644 --- a/lib/migrate/projects.rb +++ b/lib/migrate/projects.rb @@ -4,10 +4,10 @@ class FakeRepository < ::ActiveRecord::Base end class Projects < Migrate::Base - def migrate + def migrate(project_id = false) puts "Migrando projetos..." - phpsvn_projects.each do |reg| + phpsvn_projects(project_id).each do |reg| copy_repository_from_php(reg['alias']) pj = ::Project.create(name: reg['alias']) @@ -24,8 +24,12 @@ def migrate end end - def phpsvn_projects - mysql.query('select * from projetos') + def phpsvn_projects(id) + if (id) + mysql.query("select * from projetos where id = #{id}") + else + mysql.query('select * from projetos') + end end def add_users_to_project(cr_project, old_project_id) diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index a7b2e83..3eb7d52 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -9,6 +9,17 @@ namespace :cranelift do Migrate::Projects.new.migrate end + task :migrate_single_project, [:project_id] => :environment do |t, args| + args.with_defaults(:project_id => false) + unless(args.project_id) + "You need to specify a project id, e.g.: rake migrate_single_project[10]" + end + + Migrate::Users.new.migrate + Migrate::Ips.new.migrate + Migrate::Projects.new.migrate(args.project_id) + end + desc "Create fake php projects folders - to dev" task :create_fake_projects_folders => :environment do Migrate::ProjectsMigrate.new.create_fake_folders