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
511221eb
Commit
511221eb
authored
Jan 26, 2022
by
Douglas Barbosa Alexandre
Committed by
Adam Hegyi
Jan 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_builds to projects for LFK
Swaps FK for ci_builds.project_id to projects Changelog: changed
parent
abd5838c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
4 deletions
+31
-4
db/post_migrate/20220126210021_remove_projects_ci_builds_project_id_fk.rb
...20220126210021_remove_projects_ci_builds_project_id_fk.rb
+20
-0
db/schema_migrations/20220126210021
db/schema_migrations/20220126210021
+1
-0
db/structure.sql
db/structure.sql
+0
-3
lib/gitlab/database/gitlab_loose_foreign_keys.yml
lib/gitlab/database/gitlab_loose_foreign_keys.yml
+3
-0
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
+0
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+7
-0
No files found.
db/post_migrate/20220126210021_remove_projects_ci_builds_project_id_fk.rb
0 → 100644
View file @
511221eb
# frozen_string_literal: true
class
RemoveProjectsCiBuildsProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
return
if
Gitlab
.
com?
# unsafe migration, skip on GitLab.com due to https://gitlab.com/groups/gitlab-org/-/epics/7249#note_819625526
return
unless
foreign_key_exists?
(
:ci_builds
,
:projects
,
name:
"fk_befce0568a"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_builds IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_builds
,
:projects
,
name:
"fk_befce0568a"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_builds
,
:projects
,
name:
"fk_befce0568a"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220126210021
0 → 100644
View file @
511221eb
fd7940bb6f077c91d7f9928f574443ba4bf33bb90cb702c0a2ecad14398ab1cc
\ No newline at end of file
db/structure.sql
View file @
511221eb
...
@@ -29753,9 +29753,6 @@ ALTER TABLE ONLY ci_sources_pipelines
...
@@ -29753,9 +29753,6 @@ ALTER TABLE ONLY ci_sources_pipelines
ALTER TABLE ONLY packages_maven_metadata
ALTER TABLE ONLY packages_maven_metadata
ADD CONSTRAINT fk_be88aed360 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
ADD CONSTRAINT fk_be88aed360 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_builds
ADD CONSTRAINT fk_befce0568a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY design_management_versions
ALTER TABLE ONLY design_management_versions
ADD CONSTRAINT fk_c1440b4896 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
ADD CONSTRAINT fk_c1440b4896 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
511221eb
...
@@ -88,6 +88,9 @@ ci_builds:
...
@@ -88,6 +88,9 @@ ci_builds:
-
table
:
users
-
table
:
users
column
:
user_id
column
:
user_id
on_delete
:
async_nullify
on_delete
:
async_nullify
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_pipelines
:
ci_pipelines
:
-
table
:
merge_requests
-
table
:
merge_requests
column
:
merge_request_id
column
:
merge_request_id
...
...
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
511221eb
...
@@ -12,7 +12,6 @@ RSpec.describe 'cross-database foreign keys' do
...
@@ -12,7 +12,6 @@ RSpec.describe 'cross-database foreign keys' do
let
(
:allowed_cross_database_foreign_keys
)
do
let
(
:allowed_cross_database_foreign_keys
)
do
%w(
%w(
ci_build_report_results.project_id
ci_build_report_results.project_id
ci_builds.project_id
ci_daily_build_group_report_results.group_id
ci_daily_build_group_report_results.group_id
ci_daily_build_group_report_results.project_id
ci_daily_build_group_report_results.project_id
ci_freeze_periods.project_id
ci_freeze_periods.project_id
...
...
spec/models/commit_status_spec.rb
View file @
511221eb
...
@@ -987,4 +987,11 @@ RSpec.describe CommitStatus do
...
@@ -987,4 +987,11 @@ RSpec.describe CommitStatus do
commit_status
.
expire_etag_cache!
commit_status
.
expire_etag_cache!
end
end
end
end
context
'loose foreign key on ci_builds.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_build
,
project:
parent
)
}
end
end
end
end
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