diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-10-04 18:34:50 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:26:02 +0300 |
commit | 2577cc99818bd0332aa78018de666579971341c8 (patch) | |
tree | fc1b4e38a6b63ca696cc966255d6fba7b7dfc9a9 /db | |
parent | 8be06f20fc64b027911ad75e05afaf0697444d6a (diff) |
Address some feedback from last code review
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170927161718_create_gpg_key_subkeys.rb | 4 | ||||
-rw-r--r-- | db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb | 4 | ||||
-rw-r--r-- | db/schema.rb | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index ffe06ce1231..c03c40416a8 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -3,11 +3,11 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration def up create_table :gpg_key_subkeys do |t| + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + t.binary :keyid t.binary :fingerprint - t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } - t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil end diff --git a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb index 355fbfbbede..346dfb1a4b6 100644 --- a/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb +++ b/db/post_migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb @@ -28,8 +28,10 @@ class CreateGpgKeySubkeysForExistingGpgKeys < ActiveRecord::Migration end def up - GpgKey.each_batch do |batch| + GpgKey.with_subkeys.each_batch do |batch| batch.each do |gpg_key| + return if gpg_key.subkeys.any? + create_subkeys(gpg_key) && update_signatures(gpg_key) end end diff --git a/db/schema.rb b/db/schema.rb index b9de70b742a..3bcfbcc3fd1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -580,9 +580,9 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree create_table "gpg_key_subkeys", force: :cascade do |t| + t.integer "gpg_key_id", null: false t.binary "keyid" t.binary "fingerprint" - t.integer "gpg_key_id", null: false end add_index "gpg_key_subkeys", ["fingerprint"], name: "index_gpg_key_subkeys_on_fingerprint", unique: true, using: :btree |