diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-06 17:42:13 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-06 17:42:13 +0300 |
commit | 749d3383cc390ef156d0c37a1b5f9c21062e7f9c (patch) | |
tree | f6a6cc0731184fbbba3d6aab738949f2f97ac611 /db | |
parent | 4528fa9817f2f9ba9ccf330ea2c9f6575b6a3c4b (diff) | |
download | gitlab-ce-749d3383cc390ef156d0c37a1b5f9c21062e7f9c.tar.gz |
Add migration code for existing deploy keys
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20130506095501_remove_project_id_from_key.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20130506095501_remove_project_id_from_key.rb b/db/migrate/20130506095501_remove_project_id_from_key.rb index 77daf5f19ba..4214fd45d14 100644 --- a/db/migrate/20130506095501_remove_project_id_from_key.rb +++ b/db/migrate/20130506095501_remove_project_id_from_key.rb @@ -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 |