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
7fa3cb45
Commit
7fa3cb45
authored
Dec 01, 2021
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add loose foreign key for Terraform state versions
Changelog: changed
parent
0c2bda9a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
3 deletions
+6
-3
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
lib/gitlab/database/gitlab_loose_foreign_keys.yml
lib/gitlab/database/gitlab_loose_foreign_keys.yml
+4
-0
spec/db/schema_spec.rb
spec/db/schema_spec.rb
+0
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
7fa3cb45
...
...
@@ -59,7 +59,7 @@ module Ci
has_one
:runner_session
,
class_name:
'Ci::BuildRunnerSession'
,
validate:
true
,
inverse_of: :build
has_one
:trace_metadata
,
class_name:
'Ci::BuildTraceMetadata'
,
inverse_of: :build
has_many
:terraform_state_versions
,
class_name:
'Terraform::StateVersion'
,
dependent: :nullify
,
inverse_of: :build
,
foreign_key: :ci_build_id
# rubocop:disable Cop/ActiveRecordDependent
has_many
:terraform_state_versions
,
class_name:
'Terraform::StateVersion'
,
inverse_of: :build
,
foreign_key: :ci_build_id
accepts_nested_attributes_for
:runner_session
,
update_only:
true
accepts_nested_attributes_for
:job_variables
...
...
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
7fa3cb45
...
...
@@ -41,3 +41,7 @@ pages_deployments:
-
table
:
ci_builds
column
:
ci_build_id
on_delete
:
async_nullify
terraform_state_versions
:
-
table
:
ci_builds
column
:
ci_build_id
on_delete
:
async_nullify
spec/db/schema_spec.rb
View file @
7fa3cb45
...
...
@@ -81,7 +81,6 @@ RSpec.describe 'Database schema' do
subscriptions:
%w[user_id subscribable_id]
,
suggestions:
%w[commit_id]
,
taggings:
%w[tag_id taggable_id tagger_id]
,
terraform_state_versions:
%w[ci_build_id]
,
timelogs:
%w[user_id]
,
todos:
%w[target_id commit_id]
,
uploads:
%w[model_id]
,
...
...
spec/models/ci/build_spec.rb
View file @
7fa3cb45
...
...
@@ -29,7 +29,7 @@ RSpec.describe Ci::Build do
it
{
is_expected
.
to
have_one
(
:deployment
)
}
it
{
is_expected
.
to
have_one
(
:runner_session
)
}
it
{
is_expected
.
to
have_one
(
:trace_metadata
)
}
it
{
is_expected
.
to
have_many
(
:terraform_state_versions
).
dependent
(
:nullify
).
inverse_of
(
:build
)
}
it
{
is_expected
.
to
have_many
(
:terraform_state_versions
).
inverse_of
(
:build
)
}
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
...
...
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