diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-06-18 04:05:19 +0000 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-06-18 04:05:19 +0000 |
commit | b6cc32b0e01c268a6f89223e3fa2ca46a3234155 (patch) | |
tree | f58e2afd78078ac6d94d419d066e0ab2e59ba8a3 /db/post_migrate | |
parent | fc1fcba6077edc0bee33aa3030145c53af109315 (diff) | |
parent | a8ae921d99cb187226edfec4b075b0c01e83330a (diff) | |
download | gitlab-ce-b6cc32b0e01c268a6f89223e3fa2ca46a3234155.tar.gz |
Merge branch 'ashmckenzie/add-created-at-index-to-events' into 'master'
Add index to events and audit_events tables
Closes gitlab-com/Product#309
See merge request gitlab-org/gitlab-ce!29194
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20190611161642_add_index_to_events_and_audit_events_created_at_author_id.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db/post_migrate/20190611161642_add_index_to_events_and_audit_events_created_at_author_id.rb b/db/post_migrate/20190611161642_add_index_to_events_and_audit_events_created_at_author_id.rb new file mode 100644 index 00000000000..342e83d6322 --- /dev/null +++ b/db/post_migrate/20190611161642_add_index_to_events_and_audit_events_created_at_author_id.rb @@ -0,0 +1,25 @@ +# 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 AddIndexToEventsAndAuditEventsCreatedAtAuthorId < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'analytics_index_%s_on_created_at_and_author_id'.freeze + EVENTS_INDEX_NAME = (INDEX_NAME % 'events').freeze + AUDIT_EVENTS_INDEX_NAME = (INDEX_NAME % 'audit_events').freeze + + disable_ddl_transaction! + + def up + add_concurrent_index :events, [:created_at, :author_id], name: EVENTS_INDEX_NAME + add_concurrent_index :audit_events, [:created_at, :author_id], name: AUDIT_EVENTS_INDEX_NAME + end + + def down + remove_concurrent_index_by_name :events, EVENTS_INDEX_NAME + remove_concurrent_index_by_name :audit_events, AUDIT_EVENTS_INDEX_NAME + end +end |