diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 06:07:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 06:07:42 +0000 |
commit | 8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461 (patch) | |
tree | 1ffd5ffed59b0f752fc358524f4d2170f6694cb9 /db | |
parent | 2ccde70b80730fd52f75797e7d711748fb5b769b (diff) | |
download | gitlab-ce-8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20191128145231_add_ci_resource_groups.rb | 24 | ||||
-rw-r--r-- | db/migrate/20191129144631_add_index_to_resource_group_id.rb | 20 | ||||
-rw-r--r-- | db/schema.rb | 24 |
3 files changed, 68 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..0b730e47dda --- /dev/null +++ b/db/migrate/20191128145231_add_ci_resource_groups.rb @@ -0,0 +1,24 @@ +# 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.references :project, null: false, index: false, foreign_key: { on_delete: :cascade } + 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.references :build, null: true, index: true, foreign_key: { to_table: :ci_builds, on_delete: :nullify } + t.index %i[resource_group_id build_id], unique: true + end + + add_column :ci_builds, :resource_group_id, :bigint + add_column :ci_builds, :waiting_for_resource_at, :datetime_with_timezone + 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 a369db5e4df..5aa13fa8c72 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -683,6 +683,8 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) 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])))" @@ -696,6 +698,7 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) 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)" @@ -870,6 +873,23 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) 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" @@ -4364,6 +4384,7 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) 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 @@ -4384,6 +4405,9 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) 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", on_delete: :cascade + add_foreign_key "ci_resources", "ci_builds", column: "build_id", 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 |