Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-19 18:07:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-19 18:07:55 +0300
commitf92a53a216e6e7d5037ac701efbee5628f91aa9a (patch)
tree1eb957f0277b50002258681f61db869a2b683fec /db
parente3764d340e2849fccee8c06278d1f5f686edd35b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20191128145231_add_ci_resource_groups.rb22
-rw-r--r--db/migrate/20191128145232_add_fk_to_ci_resources_build_id.rb17
-rw-r--r--db/migrate/20191128145233_add_fk_to_ci_resource_groups_project_id.rb17
-rw-r--r--db/migrate/20191129144630_add_resource_group_id_to_ci_builds.rb25
-rw-r--r--db/migrate/20191129144631_add_index_to_resource_group_id.rb20
-rw-r--r--db/schema.rb24
6 files changed, 125 insertions, 0 deletions
diff --git a/db/migrate/20191128145231_add_ci_resource_groups.rb b/db/migrate/20191128145231_add_ci_resource_groups.rb
new file mode 100644
index 00000000000..8bde0254701
--- /dev/null
+++ b/db/migrate/20191128145231_add_ci_resource_groups.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddCiResourceGroups < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :ci_resource_groups do |t|
+ t.timestamps_with_timezone
+ t.bigint :project_id, null: false
+ t.string :key, null: false, limit: 255
+ t.index %i[project_id key], unique: true
+ end
+
+ create_table :ci_resources do |t|
+ t.timestamps_with_timezone
+ t.references :resource_group, null: false, index: false, foreign_key: { to_table: :ci_resource_groups, on_delete: :cascade }
+ t.bigint :build_id, null: true
+ t.index %i[build_id]
+ t.index %i[resource_group_id build_id], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191128145232_add_fk_to_ci_resources_build_id.rb b/db/migrate/20191128145232_add_fk_to_ci_resources_build_id.rb
new file mode 100644
index 00000000000..a13513de3b2
--- /dev/null
+++ b/db/migrate/20191128145232_add_fk_to_ci_resources_build_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddFkToCiResourcesBuildId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_resources, :ci_builds, column: :build_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_resources, column: :build_id
+ end
+end
diff --git a/db/migrate/20191128145233_add_fk_to_ci_resource_groups_project_id.rb b/db/migrate/20191128145233_add_fk_to_ci_resource_groups_project_id.rb
new file mode 100644
index 00000000000..bb23012ea9b
--- /dev/null
+++ b/db/migrate/20191128145233_add_fk_to_ci_resource_groups_project_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddFkToCiResourceGroupsProjectId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :ci_resource_groups, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_resource_groups, column: :project_id
+ end
+end
diff --git a/db/migrate/20191129144630_add_resource_group_id_to_ci_builds.rb b/db/migrate/20191129144630_add_resource_group_id_to_ci_builds.rb
new file mode 100644
index 00000000000..2e696c32e7e
--- /dev/null
+++ b/db/migrate/20191129144630_add_resource_group_id_to_ci_builds.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddResourceGroupIdToCiBuilds < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ unless column_exists?(:ci_builds, :resource_group_id)
+ add_column :ci_builds, :resource_group_id, :bigint
+ end
+
+ unless column_exists?(:ci_builds, :waiting_for_resource_at)
+ add_column :ci_builds, :waiting_for_resource_at, :datetime_with_timezone
+ end
+ end
+
+ def down
+ if column_exists?(:ci_builds, :resource_group_id)
+ remove_column :ci_builds, :resource_group_id, :bigint
+ end
+
+ if column_exists?(:ci_builds, :waiting_for_resource_at)
+ remove_column :ci_builds, :waiting_for_resource_at, :datetime_with_timezone
+ end
+ end
+end
diff --git a/db/migrate/20191129144631_add_index_to_resource_group_id.rb b/db/migrate/20191129144631_add_index_to_resource_group_id.rb
new file mode 100644
index 00000000000..0e5a84f094d
--- /dev/null
+++ b/db/migrate/20191129144631_add_index_to_resource_group_id.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexToResourceGroupId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_for_resource_group'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds, %i[resource_group_id id], where: 'resource_group_id IS NOT NULL', name: INDEX_NAME
+ add_concurrent_foreign_key :ci_builds, :ci_resource_groups, column: :resource_group_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :ci_builds, column: :resource_group_id
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index acf51164e0b..91fbcd42f30 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -684,6 +684,8 @@ ActiveRecord::Schema.define(version: 2019_12_16_183532) do
t.datetime_with_timezone "scheduled_at"
t.string "token_encrypted"
t.integer "upstream_pipeline_id"
+ t.bigint "resource_group_id"
+ t.datetime_with_timezone "waiting_for_resource_at"
t.index ["artifacts_expire_at"], name: "index_ci_builds_on_artifacts_expire_at", where: "(artifacts_file <> ''::text)"
t.index ["auto_canceled_by_id"], name: "index_ci_builds_on_auto_canceled_by_id"
t.index ["commit_id", "artifacts_expire_at", "id"], name: "index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial", where: "(((type)::text = 'Ci::Build'::text) AND ((retried = false) OR (retried IS NULL)) AND ((name)::text = ANY (ARRAY[('sast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('sast:container'::character varying)::text, ('container_scanning'::character varying)::text, ('dast'::character varying)::text])))"
@@ -698,6 +700,7 @@ ActiveRecord::Schema.define(version: 2019_12_16_183532) do
t.index ["project_id"], name: "index_ci_builds_on_project_id_for_successfull_pages_deploy", where: "(((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND ((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text))"
t.index ["protected"], name: "index_ci_builds_on_protected"
t.index ["queued_at"], name: "index_ci_builds_on_queued_at"
+ t.index ["resource_group_id", "id"], name: "index_for_resource_group", where: "(resource_group_id IS NOT NULL)"
t.index ["runner_id"], name: "index_ci_builds_on_runner_id"
t.index ["scheduled_at"], name: "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs", where: "((scheduled_at IS NOT NULL) AND ((type)::text = 'Ci::Build'::text) AND ((status)::text = 'scheduled'::text))"
t.index ["stage_id", "stage_idx"], name: "tmp_build_stage_position_index", where: "(stage_idx IS NOT NULL)"
@@ -872,6 +875,23 @@ ActiveRecord::Schema.define(version: 2019_12_16_183532) do
t.index ["user_id"], name: "index_ci_pipelines_on_user_id"
end
+ create_table "ci_resource_groups", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "project_id", null: false
+ t.string "key", limit: 255, null: false
+ t.index ["project_id", "key"], name: "index_ci_resource_groups_on_project_id_and_key", unique: true
+ end
+
+ create_table "ci_resources", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "resource_group_id", null: false
+ t.bigint "build_id"
+ t.index ["build_id"], name: "index_ci_resources_on_build_id"
+ t.index ["resource_group_id", "build_id"], name: "index_ci_resources_on_resource_group_id_and_build_id", unique: true
+ end
+
create_table "ci_runner_namespaces", id: :serial, force: :cascade do |t|
t.integer "runner_id"
t.integer "namespace_id"
@@ -4395,6 +4415,7 @@ ActiveRecord::Schema.define(version: 2019_12_16_183532) do
add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify
add_foreign_key "ci_builds", "ci_pipelines", column: "commit_id", name: "fk_d3130c9a7f", on_delete: :cascade
add_foreign_key "ci_builds", "ci_pipelines", column: "upstream_pipeline_id", name: "fk_87f4cefcda", on_delete: :cascade
+ add_foreign_key "ci_builds", "ci_resource_groups", column: "resource_group_id", name: "fk_6661f4f0e8", on_delete: :nullify
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_metadata", "ci_builds", column: "build_id", on_delete: :cascade
@@ -4415,6 +4436,9 @@ ActiveRecord::Schema.define(version: 2019_12_16_183532) do
add_foreign_key "ci_pipelines", "external_pull_requests", name: "fk_190998ef09", on_delete: :nullify
add_foreign_key "ci_pipelines", "merge_requests", name: "fk_a23be95014", on_delete: :cascade
add_foreign_key "ci_pipelines", "projects", name: "fk_86635dbd80", on_delete: :cascade
+ add_foreign_key "ci_resource_groups", "projects", name: "fk_774722d144", on_delete: :cascade
+ add_foreign_key "ci_resources", "ci_builds", column: "build_id", name: "fk_e169a8e3d5", on_delete: :nullify
+ add_foreign_key "ci_resources", "ci_resource_groups", column: "resource_group_id", on_delete: :cascade
add_foreign_key "ci_runner_namespaces", "ci_runners", column: "runner_id", on_delete: :cascade
add_foreign_key "ci_runner_namespaces", "namespaces", on_delete: :cascade
add_foreign_key "ci_runner_projects", "projects", name: "fk_4478a6f1e4", on_delete: :cascade