Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0f887aa6
Commit
0f887aa6
authored
Oct 14, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check new tables for existence of primary key
Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/251070
parent
cfa45547
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
spec/db/schema_spec.rb
spec/db/schema_spec.rb
+36
-0
No files found.
spec/db/schema_spec.rb
View file @
0f887aa6
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment