diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-05 18:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-05 18:08:48 +0300 |
commit | 205b6baf2677879c35968d2b659225b58e8a1227 (patch) | |
tree | 10ed06185aae2f6ed6e7c61349a92acab605daca /spec/db | |
parent | f34077e88198da754b4efecd1ce1d996ce982286 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/db')
-rw-r--r-- | spec/db/schema_spec.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index 8070e17b7af..bd13f86034a 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -114,11 +114,17 @@ RSpec.describe 'Database schema' do context 'all foreign keys' do # for index to be effective, the FK constraint has to be at first place it 'are indexed' do - first_indexed_column = indexes.map(&:columns).map do |columns| + first_indexed_column = indexes.filter_map do |index| + columns = index.columns + # In cases of complex composite indexes, a string is returned eg: # "lower((extern_uid)::text), group_id" columns = columns.split(',') if columns.is_a?(String) - columns.first.chomp + column = columns.first.chomp + + # A partial index is not suitable for a foreign key column, unless + # the only condition is for the presence of the foreign key itself + column if index.where.nil? || index.where == "(#{column} IS NOT NULL)" end foreign_keys_columns = all_foreign_keys.map(&:column) required_indexed_columns = foreign_keys_columns - ignored_index_columns(table) |