use db's on_delete instead of has_many :dependent
This commit is contained in:
parent
786b5a5991
commit
57ccff8ea4
5 changed files with 8 additions and 8 deletions
|
@ -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 @@ class User < ActiveRecord::Base
|
|||
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 @@ class CreateGpgKeys < ActiveRecord::Migration
|
|||
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 @@ class CreateGpgSignatures < ActiveRecord::Migration
|
|||
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 @@ ActiveRecord::Schema.define(version: 20170725145659) do
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue