diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 18:09:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 18:09:28 +0300 |
commit | 893ba862a7808ac7099c0d5c6d6ad618ae4e2665 (patch) | |
tree | 1465b217b3111ddc7b0120bdbbce2ebc377f42fa /db | |
parent | 7b2635a55d4e87431bae752bd44c6fd2d2657b03 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20201111145317_add_relation_to_indexes_view.rb | 58 | ||||
-rw-r--r-- | db/schema_migrations/20201111145317 | 1 | ||||
-rw-r--r-- | db/structure.sql | 1 |
3 files changed, 60 insertions, 0 deletions
diff --git a/db/migrate/20201111145317_add_relation_to_indexes_view.rb b/db/migrate/20201111145317_add_relation_to_indexes_view.rb new file mode 100644 index 00000000000..318b77c1dc6 --- /dev/null +++ b/db/migrate/20201111145317_add_relation_to_indexes_view.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +class AddRelationToIndexesView < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute(<<~SQL) + DROP VIEW postgres_indexes; + + CREATE VIEW postgres_indexes AS + SELECT (pg_namespace.nspname::text || '.'::text) || pg_class.relname::text AS identifier, + pg_index.indexrelid, + pg_namespace.nspname AS schema, + pg_class.relname AS name, + pg_indexes.tablename, + pg_index.indisunique AS "unique", + pg_index.indisvalid AS valid_index, + pg_class.relispartition AS partitioned, + pg_index.indisexclusion AS exclusion, + pg_index.indexprs IS NOT NULL as expression, + pg_index.indpred IS NOT NULL as partial, + pg_indexes.indexdef AS definition, + pg_relation_size(pg_class.oid::regclass) AS ondisk_size_bytes + FROM pg_index + JOIN pg_class ON pg_class.oid = pg_index.indexrelid + JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid + JOIN pg_indexes ON pg_class.relname = pg_indexes.indexname + WHERE pg_namespace.nspname <> 'pg_catalog'::name + AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name])); + SQL + end + + def down + execute(<<~SQL) + DROP VIEW postgres_indexes; + + CREATE VIEW postgres_indexes AS + SELECT (pg_namespace.nspname::text || '.'::text) || pg_class.relname::text AS identifier, + pg_index.indexrelid, + pg_namespace.nspname AS schema, + pg_class.relname AS name, + pg_index.indisunique AS "unique", + pg_index.indisvalid AS valid_index, + pg_class.relispartition AS partitioned, + pg_index.indisexclusion AS exclusion, + pg_index.indexprs IS NOT NULL as expression, + pg_index.indpred IS NOT NULL as partial, + pg_indexes.indexdef AS definition, + pg_relation_size(pg_class.oid::regclass) AS ondisk_size_bytes + FROM pg_index + JOIN pg_class ON pg_class.oid = pg_index.indexrelid + JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid + JOIN pg_indexes ON pg_class.relname = pg_indexes.indexname + WHERE pg_namespace.nspname <> 'pg_catalog'::name + AND (pg_namespace.nspname = ANY (ARRAY["current_schema"(), 'gitlab_partitions_dynamic'::name, 'gitlab_partitions_static'::name])); + SQL + end +end diff --git a/db/schema_migrations/20201111145317 b/db/schema_migrations/20201111145317 new file mode 100644 index 00000000000..b6b33df7645 --- /dev/null +++ b/db/schema_migrations/20201111145317 @@ -0,0 +1 @@ +51d26848722466503e43b0f41e2fa43ee6073a16b358311a0aff6d77fbb12b1d
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index d50148599b3..79958cb93fd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -14897,6 +14897,7 @@ CREATE VIEW postgres_indexes AS pg_index.indexrelid, pg_namespace.nspname AS schema, pg_class.relname AS name, + pg_indexes.tablename, pg_index.indisunique AS "unique", pg_index.indisvalid AS valid_index, pg_class.relispartition AS partitioned, |