From 528859ddcf9890c5671ff57e36df7fb24aceea31 Mon Sep 17 00:00:00 2001 From: Dylan Griffith Date: Fri, 11 May 2018 11:10:41 +0200 Subject: Add index on runner_type for ci_runners We use this to filter runner and will use this increasingly in future instead of is_shared so it should be indexed --- db/schema.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db/schema.rb') diff --git a/db/schema.rb b/db/schema.rb index 95adccf0d5c..4abca1789a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180508135515) do +ActiveRecord::Schema.define(version: 20180511090724) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -503,6 +503,7 @@ ActiveRecord::Schema.define(version: 20180508135515) do add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree + add_index "ci_runners", ["runner_type"], name: "index_ci_runners_on_runner_type", using: :btree add_index "ci_runners", ["token"], name: "index_ci_runners_on_token", using: :btree create_table "ci_stages", force: :cascade do |t| -- cgit v1.2.1 From 3126e89eb811ae76dbb46c122251485361bb69cb Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 11 May 2018 11:19:49 -0700 Subject: Add a unique and not null constraint on the project_features.project_id column This commit has two migrations: 1. The first prunes duplicate rows in the project_features table and leaves the row with the highest ID. Since the behavior was indeterministic before and depended on which row the database decided to use, this change at least makes the permissions consistent. For example, in some cases, the Wiki may have been disabled but enabled in another entry. 2. The second adds a non-null constraint on the project_features.project_id column. Closes #37882 Fixes a significant part of gitlab-com/migration#408. We found that we were overcounting Wikis because of these duplicates. On GitLab.com, there are 56 rows with duplicate entries by project_id, and 16,661 rows with NULL project_id values. --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db/schema.rb') diff --git a/db/schema.rb b/db/schema.rb index 4abca1789a0..ed29d202f91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180511090724) do +ActiveRecord::Schema.define(version: 20180512061621) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1494,7 +1494,7 @@ ActiveRecord::Schema.define(version: 20180511090724) do add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", unique: true, using: :btree create_table "project_features", force: :cascade do |t| - t.integer "project_id" + t.integer "project_id", null: false t.integer "merge_requests_access_level" t.integer "issues_access_level" t.integer "wiki_access_level" @@ -1505,7 +1505,7 @@ ActiveRecord::Schema.define(version: 20180511090724) do t.integer "repository_access_level", default: 20, null: false end - add_index "project_features", ["project_id"], name: "index_project_features_on_project_id", using: :btree + add_index "project_features", ["project_id"], name: "index_project_features_on_project_id", unique: true, using: :btree create_table "project_group_links", force: :cascade do |t| t.integer "project_id", null: false -- cgit v1.2.1