gitlab-org--gitlab-foss/db/migrate/20130506095501_remove_project_id_from_key.rb

23 lines
466 B
Ruby
Raw Normal View History

2013-05-06 08:10:05 -04:00
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'
2013-05-06 08:10:05 -04:00
remove_column :keys, :project_id
end
def down
add_column :keys, :project_id, :integer
end
end