summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-04-24 11:05:20 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-04-24 11:05:20 +0000
commitf5524d554bce7028f410f51b5fef85641a5f0216 (patch)
treea8dd94e02ec482b8acf170f23e69a5e378a6ea6a /app/models
parent26147b730f0f41650c2b7ff6ab21d645b36273c9 (diff)
parent1b9c1ac3adb3d65e51f38e37c4705d46c5618f88 (diff)
downloadgitlab-ce-f5524d554bce7028f410f51b5fef85641a5f0216.tar.gz
Merge branch '10244-add-project-ci-cd-settings' into 'master'
Introduce new ProjectCiCdSettings model with group_runners_enabled See merge request gitlab-org/gitlab-ce!18144
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb6
-rw-r--r--app/models/project_ci_cd_setting.rb16
2 files changed, 22 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index c293b0b8cf4..141f3761bfe 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -68,6 +68,11 @@ class Project < ActiveRecord::Base
after_save :update_project_statistics, if: :namespace_id_changed?
after_create :create_project_feature, unless: :project_feature
+
+ after_create :create_ci_cd_settings,
+ unless: :ci_cd_settings,
+ if: proc { ProjectCiCdSetting.available? }
+
after_create :set_last_activity_at
after_create :set_last_repository_updated_at
after_update :update_forks_visibility_level
@@ -231,6 +236,7 @@ class Project < ActiveRecord::Base
has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
has_many :project_badges, class_name: 'ProjectBadge'
+ has_one :ci_cd_settings, class_name: 'ProjectCiCdSetting'
accepts_nested_attributes_for :variables, allow_destroy: true
accepts_nested_attributes_for :project_feature, update_only: true
diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb
new file mode 100644
index 00000000000..9f10a93148c
--- /dev/null
+++ b/app/models/project_ci_cd_setting.rb
@@ -0,0 +1,16 @@
+class ProjectCiCdSetting < ActiveRecord::Base
+ belongs_to :project
+
+ # The version of the schema that first introduced this model/table.
+ MINIMUM_SCHEMA_VERSION = 20180403035759
+
+ def self.available?
+ @available ||=
+ ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION
+ end
+
+ def self.reset_column_information
+ @available = nil
+ super
+ end
+end