diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-04 12:10:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-04 12:10:55 +0000 |
commit | f2fd07aa1c0bfb732b80c3d028cd23c91547991c (patch) | |
tree | 7b2c53ef4b4caddb65b2443ecd34dfa2289719ab /lib/gitlab/database/migration_helpers.rb | |
parent | 9f0d27648937cb04d685ca9207f5c45f3ac98010 (diff) | |
download | gitlab-ce-f2fd07aa1c0bfb732b80c3d028cd23c91547991c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/database/migration_helpers.rb')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 58cdff2e977..88d34189edc 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -147,6 +147,12 @@ module Gitlab 'in the body of your migration class' end + if !options.delete(:allow_partition) && partition?(table_name) + raise ArgumentError, 'add_concurrent_index can not be used on a partitioned ' \ + 'table. Please use add_concurrent_partitioned_index on the partitioned table ' \ + 'as we need to create indexes on each partition and an index on the parent table' + end + options = options.merge({ algorithm: :concurrently }) if index_exists?(table_name, column_name, **options) @@ -1284,6 +1290,14 @@ into similar problems in the future (e.g. when new tables are created). end # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity + def partition?(table_name) + if view_exists?(:postgres_partitions) + Gitlab::Database::PostgresPartition.partition_exists?(table_name) + else + Gitlab::Database::PostgresPartition.legacy_partition_exists?(table_name) + end + end + private def multiple_columns(columns, separator: ', ') |