diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-14 18:08:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-14 18:08:47 +0000 |
commit | 93960490b8bdbc0f2ab1d102b83ec5d5b87c97a6 (patch) | |
tree | 05e12b8fc3094f8de548aff4f929ef3433a3f52e /spec/db | |
parent | 99670fc6a027caee34a6537c8def2e998d1ac5c2 (diff) | |
download | gitlab-ce-93960490b8bdbc0f2ab1d102b83ec5d5b87c97a6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/db')
-rw-r--r-- | spec/db/schema_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index c3da2c9d116..06fafbddced 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -238,6 +238,42 @@ RSpec.describe 'Database schema' do end end + context 'primary keys' do + let(:exceptions) do + %i( + analytics_language_trend_repository_languages + approval_project_rules_protected_branches + ci_build_trace_sections + deployment_merge_requests + elasticsearch_indexed_namespaces + elasticsearch_indexed_projects + issue_assignees + issues_prometheus_alert_events + issues_self_managed_prometheus_alert_events + merge_request_context_commit_diff_files + merge_request_diff_commits + merge_request_diff_files + milestone_releases + project_authorizations + project_pages_metadata + push_event_payloads + repository_languages + user_interacted_projects + users_security_dashboard_projects + ) + end + + it 'expects every table to have a primary key defined' do + connection = ActiveRecord::Base.connection + + problematic_tables = connection.tables.select do |table| + !connection.primary_key(table).present? + end.map(&:to_sym) + + expect(problematic_tables - exceptions).to be_empty + end + end + private def retrieve_columns_name_with_jsonb |