summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-09-03 12:09:11 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-09-04 16:12:50 +0200
commitf2b494cabc1c93bfb9f0c8d43b591e5029f5e7e3 (patch)
treecaf7e50e2621a37f8ea33d20565247d71796d394
parent955a6c3d429bd18716502cef1bcc1bde2759fb85 (diff)
downloadgitlab-ce-f2b494cabc1c93bfb9f0c8d43b591e5029f5e7e3.tar.gz
Use `metadata` instead of new model `build_config`.
-rw-r--r--app/models/ci/build.rb37
-rw-r--r--app/models/ci/build_config.rb20
-rw-r--r--app/models/ci/build_metadata.rb3
-rw-r--r--db/migrate/20180831115821_create_ci_builds_config.rb9
-rw-r--r--db/schema.rb11
5 files changed, 19 insertions, 61 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 2c182b02f36..eda86155aaf 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -34,7 +34,6 @@ module Ci
has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id
end
- has_one :config, class_name: 'Ci::BuildConfig'
has_one :metadata, class_name: 'Ci::BuildMetadata'
has_one :runner_session, class_name: 'Ci::BuildRunnerSession', validate: true, inverse_of: :build
@@ -537,48 +536,36 @@ module Ci
read_attribute(:when) || 'on_success'
end
- def config
- return unless BuildConfig.available?
-
- super
- end
-
- def ensure_config
- config || build_config
- end
-
def options
read_attribute(:options) ||
- config&.yaml_options ||
+ metadata&.yaml_options ||
{}
end
def options=(value)
- unless BuildConfig.available? && Feature.enabled?(:ci_use_build_config)
+ unless Feature.enabled?(:ci_use_build_metadata_for_config)
super
- return
+ else
+ # save and remove from this model
+ ensure_metadata.yaml_options = value
+ write_attribute(:options, nil)
end
-
- # save and remove from this model
- ensure_config.yaml_options = value
- write_attribute(:options, nil)
end
def yaml_variables
read_attribute(:yaml_variables) ||
- config&.yaml_variables ||
+ metadata&.yaml_variables ||
[]
end
def yaml_variables=(value)
- unless BuildConfig.available? && Feature.enabled?(:ci_use_build_config)
+ unless BuildConfig.available? && Feature.enabled?(:ci_use_build_metadata_for_config)
super
- return
+ else
+ # save and remove from this model
+ ensure_metadata.yaml_variables = value
+ write_attribute(:yaml_variables, nil)
end
-
- # save and remove from this model
- ensure_config.yaml_variables = value
- write_attribute(:yaml_variables, nil)
end
def user_variables
diff --git a/app/models/ci/build_config.rb b/app/models/ci/build_config.rb
deleted file mode 100644
index 2401b8b514b..00000000000
--- a/app/models/ci/build_config.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-module Ci
- class BuildConfig < ActiveRecord::Base
- extend Gitlab::Ci::Model
-
- # The version of the schema that first introduced this model/table.
- MINIMUM_SCHEMA_VERSION = 20180831115821
-
- def self.available?
- @available ||=
- ActiveRecord::Migrator.current_version >= MINIMUM_SCHEMA_VERSION
- end
-
- self.table_name = 'ci_builds_config'
-
- belongs_to :build
-
- serialize :yaml_options # rubocop:disable Cop/ActiveRecordSerialize
- serialize :yaml_variables, Gitlab::Serializer::Ci::Variables # rubocop:disable Cop/ActiveRecordSerialize
- end
-end
diff --git a/app/models/ci/build_metadata.rb b/app/models/ci/build_metadata.rb
index 9d588b862bd..631006edcbb 100644
--- a/app/models/ci/build_metadata.rb
+++ b/app/models/ci/build_metadata.rb
@@ -16,6 +16,9 @@ module Ci
validates :build, presence: true
validates :project, presence: true
+ serialize :yaml_options # rubocop:disable Cop/ActiveRecordSerialize
+ serialize :yaml_variables, Gitlab::Serializer::Ci::Variables # rubocop:disable Cop/ActiveRecordSerialize
+
chronic_duration_attr_reader :timeout_human_readable, :timeout
enum timeout_source: {
diff --git a/db/migrate/20180831115821_create_ci_builds_config.rb b/db/migrate/20180831115821_create_ci_builds_config.rb
index 5eafa6b7937..d3bd8d5ea6b 100644
--- a/db/migrate/20180831115821_create_ci_builds_config.rb
+++ b/db/migrate/20180831115821_create_ci_builds_config.rb
@@ -9,12 +9,7 @@ class CreateCiBuildsConfig < ActiveRecord::Migration
DOWNTIME = false
def change
- create_table :ci_builds_config, id: :bigserial do |t|
- t.integer :build_id, null: false
- t.text :yaml_options
- t.text :yaml_variables
- t.index :build_id, unique: true
- t.foreign_key :ci_builds, column: :build_id, on_delete: :cascade
- end
+ add_column :ci_builds_metadata, :yaml_options, :text
+ add_column :ci_builds_metadata, :yaml_variables, :text
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 498adc99d02..32e09568d6e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -352,19 +352,13 @@ ActiveRecord::Schema.define(version: 20180831115821) do
add_index "ci_builds", ["updated_at"], name: "index_ci_builds_on_updated_at", using: :btree
add_index "ci_builds", ["user_id"], name: "index_ci_builds_on_user_id", using: :btree
- create_table "ci_builds_config", id: :bigserial, force: :cascade do |t|
- t.integer "build_id", null: false
- t.text "yaml_options"
- t.text "yaml_variables"
- end
-
- add_index "ci_builds_config", ["build_id"], name: "index_ci_builds_config_on_build_id", unique: true, using: :btree
-
create_table "ci_builds_metadata", force: :cascade do |t|
t.integer "build_id", null: false
t.integer "project_id", null: false
t.integer "timeout"
t.integer "timeout_source", default: 1, null: false
+ t.text "yaml_options"
+ t.text "yaml_variables"
end
add_index "ci_builds_metadata", ["build_id"], name: "index_ci_builds_metadata_on_build_id", unique: true, using: :btree
@@ -2270,7 +2264,6 @@ ActiveRecord::Schema.define(version: 20180831115821) do
add_foreign_key "ci_builds", "ci_pipelines", column: "commit_id", name: "fk_d3130c9a7f", on_delete: :cascade
add_foreign_key "ci_builds", "ci_stages", column: "stage_id", name: "fk_3a9eaa254d", on_delete: :cascade
add_foreign_key "ci_builds", "projects", name: "fk_befce0568a", on_delete: :cascade
- add_foreign_key "ci_builds_config", "ci_builds", column: "build_id", on_delete: :cascade
add_foreign_key "ci_builds_metadata", "ci_builds", column: "build_id", on_delete: :cascade
add_foreign_key "ci_builds_metadata", "projects", on_delete: :cascade
add_foreign_key "ci_builds_runner_session", "ci_builds", column: "build_id", on_delete: :cascade