diff options
-rw-r--r-- | db/migrate/20190605101234_add_index_to_audit_events_created_at.rb | 20 | ||||
-rw-r--r-- | db/schema.rb | 3 |
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 |