Commit 328f4a50 authored by Rubén Dávila's avatar Rubén Dávila

Use a separate model to handle GPG subkeys

parent 37dcfb6e
......@@ -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
......
class GpgKeySubkey < ActiveRecord::Base
belongs_to :gpg_key
end
# 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
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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment