diff options
Diffstat (limited to 'spec/db/schema_spec.rb')
-rw-r--r-- | spec/db/schema_spec.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index 521b4cd4002..edb412cbb9c 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -26,10 +26,8 @@ RSpec.describe 'Database schema' do boards: %w[milestone_id iteration_id], chat_names: %w[chat_id team_id user_id], chat_teams: %w[team_id], - ci_builds: %w[erased_by_id runner_id trigger_request_id user_id], + ci_builds: %w[erased_by_id runner_id trigger_request_id], ci_namespace_monthly_usages: %w[namespace_id], - ci_pipelines: %w[user_id], - ci_pipeline_chat_data: %w[chat_name_id], # it uses the loose foreign key featue ci_runner_projects: %w[runner_id], ci_trigger_requests: %w[commit_id], cluster_providers_aws: %w[security_group_id vpc_id access_key_id], @@ -53,6 +51,7 @@ RSpec.describe 'Database schema' do identities: %w[user_id], import_failures: %w[project_id], issues: %w[last_edited_by_id state_id], + issue_emails: %w[email_message_id], jira_tracker_data: %w[jira_issue_transition_id], keys: %w[user_id], label_links: %w[target_id], @@ -66,8 +65,6 @@ RSpec.describe 'Database schema' do oauth_access_grants: %w[resource_owner_id application_id], oauth_access_tokens: %w[resource_owner_id application_id], oauth_applications: %w[owner_id], - packages_build_infos: %w[pipeline_id], - packages_package_file_build_infos: %w[pipeline_id], product_analytics_events_experimental: %w[event_id txn_id user_id], project_group_links: %w[group_id], project_statistics: %w[namespace_id], @@ -83,7 +80,6 @@ RSpec.describe 'Database schema' do subscriptions: %w[user_id subscribable_id], suggestions: %w[commit_id], taggings: %w[tag_id taggable_id tagger_id], - terraform_state_versions: %w[ci_build_id], timelogs: %w[user_id], todos: %w[target_id commit_id], uploads: %w[model_id], @@ -101,6 +97,8 @@ RSpec.describe 'Database schema' do let(:indexes) { connection.indexes(table) } let(:columns) { connection.columns(table) } let(:foreign_keys) { connection.foreign_keys(table) } + let(:loose_foreign_keys) { Gitlab::Database::LooseForeignKeys.definitions.group_by(&:from_table).fetch(table, []) } + let(:all_foreign_keys) { foreign_keys + loose_foreign_keys } # take the first column in case we're using a composite primary key let(:primary_key_column) { Array(connection.primary_key(table)).first } @@ -113,7 +111,7 @@ RSpec.describe 'Database schema' do columns = columns.split(',') if columns.is_a?(String) columns.first.chomp end - foreign_keys_columns = foreign_keys.map(&:column) + foreign_keys_columns = all_foreign_keys.map(&:column) # Add the primary key column to the list of indexed columns because # postgres and mysql both automatically create an index on the primary @@ -128,7 +126,7 @@ RSpec.describe 'Database schema' do context 'columns ending with _id' do let(:column_names) { columns.map(&:name) } let(:column_names_with_id) { column_names.select { |column_name| column_name.ends_with?('_id') } } - let(:foreign_keys_columns) { foreign_keys.map(&:column) } + let(:foreign_keys_columns) { all_foreign_keys.map(&:column).uniq } # we can have FK and loose FK present at the same time let(:ignored_columns) { ignored_fk_columns(table) } it 'do have the foreign keys' do @@ -170,7 +168,7 @@ RSpec.describe 'Database schema' do 'PrometheusMetric' => %w[group], 'ResourceLabelEvent' => %w[action], 'User' => %w[layout dashboard project_view], - 'UserCallout' => %w[feature_name], + 'Users::Callout' => %w[feature_name], 'PrometheusAlert' => %w[operator] }.freeze |