-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
70 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Migrate | ||
class IpsMigrate < Migrate::Base | ||
class Ips < Migrate::Base | ||
def migrate | ||
puts "Migrando ips..." | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Migrate | ||
class FakeRepository < ::ActiveRecord::Base | ||
self.table_name = 'repositories' | ||
end | ||
|
||
class Projects < Migrate::Base | ||
def migrate | ||
puts "Migrando projetos..." | ||
|
||
phpsvn_projects.each do |reg| | ||
copy_repository_from_php(reg['alias']) | ||
|
||
pj = ::Project.create(name: reg['alias']) | ||
debug_obj(pj) | ||
|
||
repo = FakeRepository.create(name: reg['alias'], | ||
url: reg['nome'], | ||
enable_autoupdate: reg['autoupdate'], | ||
login: reg['co_login'], | ||
password: reg['co_password'], | ||
project_id: pj.id) | ||
|
||
add_users_to_project(pj, reg['id']) | ||
end | ||
end | ||
|
||
def phpsvn_projects | ||
mysql.query('select * from projetos') | ||
end | ||
|
||
def add_users_to_project(cr_project, old_project_id) | ||
regs = mysql.query("select * from user_projetos | ||
where id_projetos = #{old_project_id}") | ||
|
||
users_ids = regs.map{ |reg| ::Migrate::UserMap.new_id(reg['id_user']) } | ||
debugger if users_ids.include?(0) | ||
cr_project.users = ::User.find(users_ids) if users_ids.any? | ||
end | ||
|
||
def copy_repository_from_php(repository) | ||
origin = File.join(config.php_projects_path, repository) | ||
destiny = Rails.root.join('repositories', repository) | ||
|
||
FileUtils.mkdir destiny | ||
FileUtils.cp_r Dir[origin], File.join(destiny, ''), :verbose => true | ||
end | ||
|
||
def create_fake_folders | ||
puts "Criando pastas fakes para desenvolvimento..." | ||
|
||
regs = mysql.query('select * from projetos') | ||
regs.each do |r| | ||
name = r['alias'] | ||
FileUtils.mkpath File.join(config.php_projects_path, name, name) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
require 'ostruct' | ||
|
||
require 'migrate/base' | ||
require 'migrate/users_migrate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters