summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2019-07-29 11:07:32 +0200
committerAndreas Brandl <abrandl@gitlab.com>2019-07-29 11:08:46 +0200
commit398b3baefe40ed5ebce4705fec504151046b4f46 (patch)
tree56fae343ac61ca2c0178f9227859360116ab2770
parentaa0d8b4cbac34c3aac20fbb45c676e0c8d22f1f9 (diff)
downloadgitlab-ce-ab-add-index-on-environments.tar.gz
Create index on environments by stateab-add-index-on-environments
-rw-r--r--changelogs/unreleased/ab-add-index-on-environments.yml5
-rw-r--r--db/migrate/20190729090456_add_index_on_environments_with_state.rb17
-rw-r--r--db/schema.rb3
3 files changed, 24 insertions, 1 deletions
diff --git a/changelogs/unreleased/ab-add-index-on-environments.yml b/changelogs/unreleased/ab-add-index-on-environments.yml
new file mode 100644
index 00000000000..6c7641912f4
--- /dev/null
+++ b/changelogs/unreleased/ab-add-index-on-environments.yml
@@ -0,0 +1,5 @@
+---
+title: Create index on environments by state
+merge_request: 31231
+author:
+type: performance
diff --git a/db/migrate/20190729090456_add_index_on_environments_with_state.rb b/db/migrate/20190729090456_add_index_on_environments_with_state.rb
new file mode 100644
index 00000000000..9a8d8391415
--- /dev/null
+++ b/db/migrate/20190729090456_add_index_on_environments_with_state.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnEnvironmentsWithState < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :environments, [:project_id, :state]
+ end
+
+ def down
+ remove_concurrent_index :environments, [:project_id, :state]
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1b5272179f5..71e72668d5d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_07_25_012225) do
+ActiveRecord::Schema.define(version: 2019_07_29_090456) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -1172,6 +1172,7 @@ ActiveRecord::Schema.define(version: 2019_07_25_012225) do
t.index ["name"], name: "index_environments_on_name_varchar_pattern_ops", opclass: :varchar_pattern_ops
t.index ["project_id", "name"], name: "index_environments_on_project_id_and_name", unique: true
t.index ["project_id", "slug"], name: "index_environments_on_project_id_and_slug", unique: true
+ t.index ["project_id", "state"], name: "index_environments_on_project_id_and_state"
end
create_table "epic_issues", id: :serial, force: :cascade do |t|