Commit 57ccff8e authored by Alexis Reigel's avatar Alexis Reigel
Browse files

use db's on_delete instead of has_many :dependent

parent 6614d5e5e2b4
......@@ -7,7 +7,7 @@ class GpgKey < ActiveRecord::Base
sha_attribute :fingerprint
belongs_to :user
has_many :gpg_signatures, dependent: :nullify
has_many :gpg_signatures
validates :user, presence: true
......
......@@ -76,7 +76,7 @@ def update_tracked_fields!(request)
where(type.not_eq('DeployKey').or(type.eq(nil)))
end, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :deploy_keys, -> { where(type: 'DeployKey') }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :gpg_keys, dependent: :destroy
has_many :gpg_keys
has_many :emails, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :personal_access_tokens, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
......
......@@ -5,7 +5,7 @@ def change
create_table :gpg_keys do |t|
t.timestamps_with_timezone null: false
t.references :user, index: true, foreign_key: true
t.references :user, index: true, foreign_key: { on_delete: :cascade }
t.binary :primary_keyid, limit: Gitlab::Database.mysql? ? 20 : nil
t.binary :fingerprint, limit: Gitlab::Database.mysql? ? 20 : nil
......
......@@ -5,8 +5,8 @@ def change
create_table :gpg_signatures do |t|
t.timestamps_with_timezone null: false
t.references :project, index: true, foreign_key: true
t.references :gpg_key, index: true, foreign_key: true
t.references :project, index: true, foreign_key: { on_delete: :cascade }
t.references :gpg_key, index: true, foreign_key: { on_delete: :nullify }
t.boolean :valid_signature
......
......@@ -1631,9 +1631,9 @@
add_foreign_key "environments", "projects", name: "fk_d1c8c1da6a", on_delete: :cascade
add_foreign_key "events", "projects", name: "fk_0434b48643", 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_keys", "users"
add_foreign_key "gpg_signatures", "gpg_keys"
add_foreign_key "gpg_signatures", "projects"
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
add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade
add_foreign_key "issue_assignees", "users", name: "fk_5e0c8d9154", on_delete: :cascade
add_foreign_key "issue_metrics", "issues", 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