2016-06-09 08:39:16 -04:00
|
|
|
# rubocop:disable all
|
2013-05-06 08:10:05 -04:00
|
|
|
class RemoveProjectIdFromKey < ActiveRecord::Migration
|
|
|
|
def up
|
2013-05-06 10:42:13 -04:00
|
|
|
puts 'Migrate deploy keys: '
|
|
|
|
Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey')
|
|
|
|
|
|
|
|
DeployKey.all.each do |key|
|
2014-01-19 13:55:59 -05:00
|
|
|
project = Project.find_by(id: key.project_id)
|
2013-05-06 10:42:13 -04:00
|
|
|
if project
|
|
|
|
project.deploy_keys << key
|
|
|
|
print '.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
puts 'Done'
|
|
|
|
|
2013-05-06 08:10:05 -04:00
|
|
|
remove_column :keys, :project_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_column :keys, :project_id, :integer
|
|
|
|
end
|
|
|
|
end
|