Skip to content

Commit

Permalink
add task to migrate a single php project
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloisr committed May 5, 2013
1 parent d12f4b2 commit f29b38d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/migrate/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions lib/tasks/migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f29b38d

Please sign in to comment.