summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 09:09:31 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-18 09:09:31 +0000
commit6763d2787670bc03a36a8eb601703e88fc70dece (patch)
treeedc653ffd3052e3f9898c4fa8a07621d51574767 /db
parented9165c2abda1dca048a8d3cb8030d906c0bbb0c (diff)
downloadgitlab-ce-6763d2787670bc03a36a8eb601703e88fc70dece.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200204131831_create_daily_report_results.rb22
-rw-r--r--db/migrate/20200311074438_migrate_bot_type_to_user_type.rb13
-rw-r--r--db/migrate/20200311082301_add_user_state_index.rb21
-rw-r--r--db/schema.rb17
4 files changed, 71 insertions, 2 deletions
diff --git a/db/migrate/20200204131831_create_daily_report_results.rb b/db/migrate/20200204131831_create_daily_report_results.rb
new file mode 100644
index 00000000000..e18d4efb7fa
--- /dev/null
+++ b/db/migrate/20200204131831_create_daily_report_results.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class CreateDailyReportResults < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :ci_daily_report_results do |t|
+ t.date :date, null: false
+ t.bigint :project_id, null: false
+ t.bigint :last_pipeline_id, null: false
+ t.float :value, null: false
+ t.integer :param_type, limit: 8, null: false
+ t.string :ref_path, null: false # rubocop:disable Migration/AddLimitToStringColumns
+ t.string :title, null: false # rubocop:disable Migration/AddLimitToStringColumns
+
+ t.index :last_pipeline_id
+ t.index [:project_id, :ref_path, :param_type, :date, :title], name: 'index_daily_report_results_unique_columns', unique: true
+ t.foreign_key :projects, on_delete: :cascade
+ t.foreign_key :ci_pipelines, column: :last_pipeline_id, on_delete: :cascade
+ end
+ end
+end
diff --git a/db/migrate/20200311074438_migrate_bot_type_to_user_type.rb b/db/migrate/20200311074438_migrate_bot_type_to_user_type.rb
new file mode 100644
index 00000000000..b13842794d3
--- /dev/null
+++ b/db/migrate/20200311074438_migrate_bot_type_to_user_type.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class MigrateBotTypeToUserType < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ execute('UPDATE users SET user_type = bot_type WHERE bot_type IS NOT NULL AND user_type IS NULL')
+ end
+
+ def down
+ execute('UPDATE users SET user_type = NULL WHERE bot_type IS NOT NULL AND bot_type = user_type')
+ end
+end
diff --git a/db/migrate/20200311082301_add_user_state_index.rb b/db/migrate/20200311082301_add_user_state_index.rb
new file mode 100644
index 00000000000..953941c2a53
--- /dev/null
+++ b/db/migrate/20200311082301_add_user_state_index.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddUserStateIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:users, [:state, :user_type], where: 'ghost IS NOT TRUE', name: 'index_users_on_state_and_user_type_internal')
+ remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal_ee')
+ remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal')
+ end
+
+ def down
+ add_concurrent_index(:users, :state, where: 'ghost IS NOT TRUE AND bot_type IS NULL', name: 'index_users_on_state_and_internal_ee')
+ add_concurrent_index(:users, :state, where: 'ghost IS NOT TRUE', name: 'index_users_on_state_and_internal')
+ remove_concurrent_index_by_name(:users, 'index_users_on_state_and_internal_ee')
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 55c99cb1027..1e32f4e6bd4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -738,6 +738,18 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
t.index ["build_id"], name: "index_ci_builds_runner_session_on_build_id", unique: true
end
+ create_table "ci_daily_report_results", force: :cascade do |t|
+ t.date "date", null: false
+ t.bigint "project_id", null: false
+ t.bigint "last_pipeline_id", null: false
+ t.float "value", null: false
+ t.bigint "param_type", null: false
+ t.string "ref_path", null: false
+ t.string "title", null: false
+ t.index ["last_pipeline_id"], name: "index_ci_daily_report_results_on_last_pipeline_id"
+ t.index ["project_id", "ref_path", "param_type", "date", "title"], name: "index_daily_report_results_unique_columns", unique: true
+ end
+
create_table "ci_group_variables", id: :serial, force: :cascade do |t|
t.string "key", null: false
t.text "value"
@@ -4419,9 +4431,8 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
t.index ["name"], name: "index_users_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["public_email"], name: "index_users_on_public_email", where: "((public_email)::text <> ''::text)"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ t.index ["state", "user_type"], name: "index_users_on_state_and_user_type_internal", where: "(ghost IS NOT TRUE)"
t.index ["state"], name: "index_users_on_state"
- t.index ["state"], name: "index_users_on_state_and_internal", where: "(ghost IS NOT TRUE)"
- t.index ["state"], name: "index_users_on_state_and_internal_ee", where: "((ghost IS NOT TRUE) AND (bot_type IS NULL))"
t.index ["static_object_token"], name: "index_users_on_static_object_token", unique: true
t.index ["unconfirmed_email"], name: "index_users_on_unconfirmed_email", where: "(unconfirmed_email IS NOT NULL)"
t.index ["user_type"], name: "index_users_on_user_type"
@@ -4765,6 +4776,8 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do
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
+ add_foreign_key "ci_daily_report_results", "ci_pipelines", column: "last_pipeline_id", on_delete: :cascade
+ add_foreign_key "ci_daily_report_results", "projects", on_delete: :cascade
add_foreign_key "ci_group_variables", "namespaces", column: "group_id", name: "fk_33ae4d58d8", on_delete: :cascade
add_foreign_key "ci_job_artifacts", "ci_builds", column: "job_id", on_delete: :cascade
add_foreign_key "ci_job_artifacts", "projects", on_delete: :cascade