Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
24298c7792fa
Commit
24298c77
authored
May 28, 2018
by
Kamil Trzciński
Browse files
Add `Ci::Runner` inverse_of's
parent
7c9dd8988fab
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/models/ci/runner.rb
View file @
24298c77
...
...
@@ -12,5 +12,5 @@
FORM_EDITABLE
=
%i[description tag_list active run_untagged locked access_level maximum_timeout_human_readable]
.
freeze
has_many
:builds
has_many
:runner_projects
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:runner_projects
,
inverse_of: :runner
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:projects
,
through: :runner_projects
...
...
@@ -16,5 +16,5 @@
has_many
:projects
,
through: :runner_projects
has_many
:runner_namespaces
has_many
:runner_namespaces
,
inverse_of: :runner
has_many
:groups
,
through: :runner_namespaces
has_one
:last_build
,
->
()
{
order
(
'id DESC'
)
},
class_name:
'Ci::Build'
...
...
app/models/ci/runner_namespace.rb
View file @
24298c77
...
...
@@ -2,8 +2,8 @@
class
RunnerNamespace
<
ActiveRecord
::
Base
extend
Gitlab
::
Ci
::
Model
belongs_to
:runner
,
validate:
true
belongs_to
:namespace
,
class_name:
'::Namespace'
belongs_to
:runner
,
inverse_of: :runner_namespaces
,
validate:
true
belongs_to
:namespace
,
inverse_of: :runner_namespaces
,
class_name:
'::Namespace'
belongs_to
:group
,
class_name:
'::Group'
,
foreign_key: :namespace_id
end
end
app/models/ci/runner_project.rb
View file @
24298c77
...
...
@@ -2,8 +2,8 @@
class
RunnerProject
<
ActiveRecord
::
Base
extend
Gitlab
::
Ci
::
Model
belongs_to
:runner
belongs_to
:project
belongs_to
:runner
,
inverse_of: :runner_projects
belongs_to
:project
,
inverse_of: :runner_projects
validates
:runner_id
,
uniqueness:
{
scope: :project_id
}
end
...
...
app/models/namespace.rb
View file @
24298c77
...
...
@@ -21,7 +21,7 @@
has_many
:projects
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:project_statistics
has_many
:runner_namespaces
,
class_name:
'Ci::RunnerNamespace'
has_many
:runner_namespaces
,
inverse_of: :namespace
,
class_name:
'Ci::RunnerNamespace'
has_many
:runners
,
through: :runner_namespaces
,
source: :runner
,
class_name:
'Ci::Runner'
# This should _not_ be `inverse_of: :namespace`, because that would also set
...
...
app/models/project.rb
View file @
24298c77
...
...
@@ -236,7 +236,7 @@
has_many
:builds
,
class_name:
'Ci::Build'
,
inverse_of: :project
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:build_trace_section_names
,
class_name:
'Ci::BuildTraceSectionName'
has_many
:build_trace_chunks
,
class_name:
'Ci::BuildTraceChunk'
,
through: :builds
,
source: :trace_chunks
has_many
:runner_projects
,
class_name:
'Ci::RunnerProject'
has_many
:runner_projects
,
class_name:
'Ci::RunnerProject'
,
inverse_of: :project
has_many
:runners
,
through: :runner_projects
,
source: :runner
,
class_name:
'Ci::Runner'
has_many
:variables
,
class_name:
'Ci::Variable'
has_many
:triggers
,
class_name:
'Ci::Trigger'
...
...
Write
Preview
Supports
Markdown
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