diff options
Diffstat (limited to 'spec/db')
-rw-r--r-- | spec/db/docs_spec.rb | 5 | ||||
-rw-r--r-- | spec/db/schema_spec.rb | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/spec/db/docs_spec.rb b/spec/db/docs_spec.rb index 20746e107fb..ad3705c3dbe 100644 --- a/spec/db/docs_spec.rb +++ b/spec/db/docs_spec.rb @@ -4,8 +4,11 @@ require 'spec_helper' RSpec.describe 'Database Documentation' do context 'for each table' do + # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/366834 + let(:database_base_models) { Gitlab::Database.database_base_models.select { |k, _| k != 'geo' } } + let(:all_tables) do - Gitlab::Database.database_base_models.flat_map { |_, m| m.connection.tables }.sort.uniq + database_base_models.flat_map { |_, m| m.connection.tables }.sort.uniq end let(:metadata_required_fields) do 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) |