summaryrefslogtreecommitdiff
path: root/spec/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/db
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/db')
-rw-r--r--spec/db/docs_spec.rb5
-rw-r--r--spec/db/schema_spec.rb10
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)