diff options
-rw-r--r-- | app/models/gpg_key.rb | 2 | ||||
-rw-r--r-- | app/models/gpg_key_subkey.rb | 3 | ||||
-rw-r--r-- | db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb | 10 | ||||
-rw-r--r-- | db/migrate/20170927161718_create_gpg_key_subkeys.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 10 |
5 files changed, 22 insertions, 12 deletions
diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index 683efcebee9..110ff4ee59c 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -10,7 +10,7 @@ class GpgKey < ActiveRecord::Base belongs_to :user belongs_to :parent, class_name: 'GpgKey' has_many :gpg_signatures - has_many :subkeys, class_name: 'GpgKey', foreign_key: :parent_id, dependent: :destroy + has_many :subkeys, class_name: 'GpgKeySubkey' validates :user, presence: true diff --git a/app/models/gpg_key_subkey.rb b/app/models/gpg_key_subkey.rb new file mode 100644 index 00000000000..4f967f1e47c --- /dev/null +++ b/app/models/gpg_key_subkey.rb @@ -0,0 +1,3 @@ +class GpgKeySubkey < ActiveRecord::Base + belongs_to :gpg_key +end diff --git a/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb b/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb deleted file mode 100644 index ef7675be106..00000000000 --- a/db/migrate/20170926050624_add_parent_id_to_gpg_keys.rb +++ /dev/null @@ -1,10 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddParentIdToGpgKeys < ActiveRecord::Migration - DOWNTIME = false - - def change - add_column :gpg_keys, :parent_id, :integer - end -end diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb new file mode 100644 index 00000000000..d61b669f517 --- /dev/null +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -0,0 +1,9 @@ +class CreateGpgKeySubkeys < ActiveRecord::Migration + def change + create_table :gpg_key_subkeys do |t| + t.binary :keyid + t.binary :fingerprint + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9b1457c9a03..0d02e584d0c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -579,6 +579,14 @@ 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.binary "keyid" + t.binary "fingerprint" + t.integer "gpg_key_id", null: false + end + + add_index "gpg_key_subkeys", ["gpg_key_id"], name: "index_gpg_key_subkeys_on_gpg_key_id", using: :btree + create_table "gpg_keys", force: :cascade do |t| t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false @@ -586,7 +594,6 @@ ActiveRecord::Schema.define(version: 20171004121444) do t.binary "primary_keyid" t.binary "fingerprint" t.text "key" - t.integer "parent_id" end add_index "gpg_keys", ["fingerprint"], name: "index_gpg_keys_on_fingerprint", unique: true, using: :btree @@ -1727,6 +1734,7 @@ ActiveRecord::Schema.define(version: 20171004121444) do add_foreign_key "events", "projects", on_delete: :cascade add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade + add_foreign_key "gpg_key_subkeys", "gpg_keys", on_delete: :cascade add_foreign_key "gpg_keys", "users", on_delete: :cascade add_foreign_key "gpg_signatures", "gpg_keys", on_delete: :nullify add_foreign_key "gpg_signatures", "projects", on_delete: :cascade |