Add migration code for existing deploy keys
This commit is contained in:
parent
4528fa9817
commit
749d3383cc
1 changed files with 13 additions and 0 deletions
|
@ -1,5 +1,18 @@
|
|||
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…
Reference in a new issue