98bb435f42
Migrations shouldn't fail RuboCop checks - especially lint checks, such as the nested method check. To avoid changing code in existing migrations, add the magic comment to the top of each of them to skip that file.
23 lines
489 B
Ruby
23 lines
489 B
Ruby
# rubocop:disable all
|
|
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
|
|
|
|
def down
|
|
add_column :keys, :project_id, :integer
|
|
end
|
|
end
|