diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-12 00:09:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-12 00:09:44 +0000 |
commit | 88544d284c0a25d45ea51c1817fcab1c7e99afe7 (patch) | |
tree | 7ae1c1fb6982eadb803de5f80e069fac8574e84d /db | |
parent | 15f6e7bab546b32b7ada8aa2019b06b7bda12c1d (diff) | |
download | gitlab-ce-88544d284c0a25d45ea51c1817fcab1c7e99afe7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20201103171537_add_index_active_billable_users_to_user.rb | 21 | ||||
-rw-r--r-- | db/schema_migrations/20201103171537 | 1 | ||||
-rw-r--r-- | db/structure.sql | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20201103171537_add_index_active_billable_users_to_user.rb b/db/migrate/20201103171537_add_index_active_billable_users_to_user.rb new file mode 100644 index 00000000000..3ad7a3f4ca3 --- /dev/null +++ b/db/migrate/20201103171537_add_index_active_billable_users_to_user.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexActiveBillableUsersToUser < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'active_billable_users' + HUMAN_TYPE = 'NULL' + HUMAN_SVC_BOT_TYPES = "#{HUMAN_TYPE}, 6, 4" + BOT_TYPES = '2,6,1,3,7,8' + + disable_ddl_transaction! + + def up + add_concurrent_index :users, :id, name: INDEX_NAME, where: "(state = 'active' AND (user_type is #{HUMAN_TYPE} or user_type in (#{HUMAN_SVC_BOT_TYPES}))) and ((users.user_type IS #{HUMAN_TYPE}) OR (users.user_type <> ALL ('{#{BOT_TYPES}}')))" + end + + def down + remove_concurrent_index_by_name(:users, INDEX_NAME) + end +end diff --git a/db/schema_migrations/20201103171537 b/db/schema_migrations/20201103171537 new file mode 100644 index 00000000000..4621c0e4802 --- /dev/null +++ b/db/schema_migrations/20201103171537 @@ -0,0 +1 @@ +3120428427e3c0c94799501b1d31f384c98899f2ef9bda6f95066c94afd5ecf8
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 2f6524ff0f9..138b631ba89 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -19862,6 +19862,8 @@ CREATE INDEX product_analytics_events_exper_project_id_collector_tstamp_idx9 ON CREATE INDEX product_analytics_events_experi_project_id_collector_tstamp_idx ON gitlab_partitions_static.product_analytics_events_experimental_00 USING btree (project_id, collector_tstamp); +CREATE INDEX active_billable_users ON users USING btree (id) WHERE (((state)::text = 'active'::text) AND ((user_type IS NULL) OR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL) OR (user_type <> ALL ('{2,6,1,3,7,8}'::smallint[])))); + CREATE INDEX analytics_index_audit_events_on_created_at_and_author_id ON audit_events USING btree (created_at, author_id); CREATE INDEX analytics_index_events_on_created_at_and_author_id ON events USING btree (created_at, author_id); |