summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-06-05 20:38:48 +1000
committerAsh McKenzie <amckenzie@gitlab.com>2019-06-05 20:38:48 +1000
commita0cc18b4d09793d58a26dcfc877421225c1445ca (patch)
treec622be6b222afe6bab330653cb22ef57a5b705e1
parenteebdfbc334a66064b2d9972bbe8b5f35e2fe9746 (diff)
downloadgitlab-ce-ashmckenzie/add-created-at-index-to-audit-events.tar.gz
Add created_at index to audit_events tableashmckenzie/add-created-at-index-to-audit-events
-rw-r--r--db/migrate/20190605101234_add_index_to_audit_events_created_at.rb20
-rw-r--r--db/schema.rb3
2 files changed, 22 insertions, 1 deletions
diff --git a/db/migrate/20190605101234_add_index_to_audit_events_created_at.rb b/db/migrate/20190605101234_add_index_to_audit_events_created_at.rb
new file mode 100644
index 00000000000..845cc6ee0e7
--- /dev/null
+++ b/db/migrate/20190605101234_add_index_to_audit_events_created_at.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddIndexToAuditEventsCreatedAt < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :audit_events, [:created_at, :id]
+ end
+
+ def down
+ remove_concurrent_index :audit_events, [:created_at, :id]
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fcf9e397ac1..0e6df030d4c 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: 20190530154715) do
+ActiveRecord::Schema.define(version: 20190605101234) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -205,6 +205,7 @@ ActiveRecord::Schema.define(version: 20190530154715) do
t.text "details"
t.datetime "created_at"
t.datetime "updated_at"
+ t.index ["created_at", "id"], name: "index_audit_events_on_created_at_and_id", using: :btree
t.index ["entity_id", "entity_type"], name: "index_audit_events_on_entity_id_and_entity_type", using: :btree
end