Commit 749d3383 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add migration code for existing deploy keys

parent 4528fa98
class RemoveProjectIdFromKey < ActiveRecord::Migration class RemoveProjectIdFromKey < ActiveRecord::Migration
def up def up
puts 'Migrate deploy keys: '
Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey')
DeployKey.all.each do |key|
project = Project.find_by_id(key.project_id)
if project
project.deploy_keys << key
print '.'
end
end
puts 'Done'
remove_column :keys, :project_id remove_column :keys, :project_id
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment