Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1c719423
Commit
1c719423
authored
Dec 15, 2021
by
Adam Hegyi
Committed by
Patrick Bair
Dec 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup leftover loose foreign key tracked tables
parent
f8c832e2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
6 deletions
+49
-6
app/models/user.rb
app/models/user.rb
+2
-2
lib/gitlab/database/gitlab_loose_foreign_keys.yml
lib/gitlab/database/gitlab_loose_foreign_keys.yml
+18
-0
spec/db/schema_spec.rb
spec/db/schema_spec.rb
+1
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+5
-0
spec/models/ci/job_artifact_spec.rb
spec/models/ci/job_artifact_spec.rb
+4
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+5
-0
spec/models/external_pull_request_spec.rb
spec/models/external_pull_request_spec.rb
+4
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+4
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+6
-2
No files found.
app/models/user.rb
View file @
1c719423
...
...
@@ -187,8 +187,8 @@ class User < ApplicationRecord
has_one
:abuse_report
,
dependent: :destroy
,
foreign_key: :user_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:reported_abuse_reports
,
dependent: :destroy
,
foreign_key: :reporter_id
,
class_name:
"AbuseReport"
# rubocop:disable Cop/ActiveRecordDependent
has_many
:spam_logs
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
# rubocop:disable Cop/ActiveRecordDependent
has_many
:pipelines
,
dependent: :nullify
,
class_name:
'Ci::Pipeline'
# rubocop:disable Cop/ActiveRecordDependent
has_many
:builds
,
class_name:
'Ci::Build'
has_many
:pipelines
,
class_name:
'Ci::Pipeline'
has_many
:todos
has_many
:notification_settings
has_many
:award_emoji
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
...
...
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
1c719423
...
...
@@ -22,6 +22,20 @@ ci_namespace_mirrors:
-
table
:
namespaces
column
:
namespace_id
on_delete
:
async_delete
ci_builds
:
-
table
:
users
column
:
user_id
on_delete
:
async_nullify
ci_pipelines
:
-
table
:
merge_requests
column
:
merge_request_id
on_delete
:
async_delete
-
table
:
external_pull_requests
column
:
external_pull_request_id
on_delete
:
async_nullify
-
table
:
users
column
:
user_id
on_delete
:
async_nullify
ci_project_mirrors
:
-
table
:
projects
column
:
project_id
...
...
@@ -49,3 +63,7 @@ merge_request_metrics:
-
table
:
ci_pipelines
column
:
pipeline_id
on_delete
:
async_delete
project_pages_metadata
:
-
table
:
ci_job_artifacts
column
:
artifacts_archive_id
on_delete
:
async_nullify
spec/db/schema_spec.rb
View file @
1c719423
...
...
@@ -26,9 +26,8 @@ RSpec.describe 'Database schema' do
boards:
%w[milestone_id iteration_id]
,
chat_names:
%w[chat_id team_id user_id]
,
chat_teams:
%w[team_id]
,
ci_builds:
%w[erased_by_id runner_id trigger_request_id
user_id
]
,
ci_builds:
%w[erased_by_id runner_id trigger_request_id]
,
ci_namespace_monthly_usages:
%w[namespace_id]
,
ci_pipelines:
%w[user_id]
,
ci_runner_projects:
%w[runner_id]
,
ci_trigger_requests:
%w[commit_id]
,
cluster_providers_aws:
%w[security_group_id vpc_id access_key_id]
,
...
...
spec/models/ci/build_spec.rb
View file @
1c719423
...
...
@@ -5421,4 +5421,9 @@ RSpec.describe Ci::Build do
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:ci_build
}
end
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:model
)
{
create
(
:ci_build
,
user:
create
(
:user
))
}
let!
(
:parent
)
{
model
.
user
}
end
end
spec/models/ci/job_artifact_spec.rb
View file @
1c719423
...
...
@@ -700,4 +700,8 @@ RSpec.describe Ci::JobArtifact do
when changes or new entries are made.
MSG
end
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:ci_job_artifact
}
end
end
spec/models/ci/pipeline_spec.rb
View file @
1c719423
...
...
@@ -4672,4 +4672,9 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:ci_pipeline
}
end
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:model
)
{
create
(
:ci_pipeline
,
user:
create
(
:user
))
}
let!
(
:parent
)
{
model
.
user
}
end
end
spec/models/external_pull_request_spec.rb
View file @
1c719423
...
...
@@ -232,4 +232,8 @@ RSpec.describe ExternalPullRequest do
'with space/README.md'
]
end
end
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:external_pull_request
}
end
end
spec/models/merge_request_spec.rb
View file @
1c719423
...
...
@@ -5042,4 +5042,8 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect
(
described_class
.
from_fork
).
to
eq
([
fork_mr
])
end
end
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:merge_request
}
end
end
spec/models/user_spec.rb
View file @
1c719423
...
...
@@ -110,8 +110,8 @@ RSpec.describe User do
it
{
is_expected
.
to
have_many
(
:spam_logs
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:todos
)
}
it
{
is_expected
.
to
have_many
(
:award_emoji
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:builds
)
.
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
)
.
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:builds
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
)
}
it
{
is_expected
.
to
have_many
(
:chat_names
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:uploads
)
}
it
{
is_expected
.
to
have_many
(
:reported_abuse_reports
).
dependent
(
:destroy
).
class_name
(
'AbuseReport'
)
}
...
...
@@ -6303,4 +6303,8 @@ RSpec.describe User do
expect
(
user
.
user_readme
).
to
be
(
nil
)
end
end
it_behaves_like
'it has loose foreign keys'
do
let
(
:factory_name
)
{
:user
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment