Skip to content
Snippets Groups Projects
Commit 749d3383 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add migration code for existing deploy keys

parent 4528fa98
No related branches found
No related tags found
No related merge requests found
class RemoveProjectIdFromKey < ActiveRecord::Migration
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
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment