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
3383b327
Commit
3383b327
authored
Jan 24, 2022
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_refs to projects for LFK
Swaps FK for ci_refs.project_id to projects Changelog: changed
parent
ea0d8ca9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
4 deletions
+32
-4
db/post_migrate/20220124214131_remove_projects_ci_refs_project_id_fk.rb
...e/20220124214131_remove_projects_ci_refs_project_id_fk.rb
+20
-0
db/schema_migrations/20220124214131
db/schema_migrations/20220124214131
+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
+4
-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/ci/ref_spec.rb
spec/models/ci/ref_spec.rb
+7
-0
No files found.
db/post_migrate/20220124214131_remove_projects_ci_refs_project_id_fk.rb
0 → 100644
View file @
3383b327
# frozen_string_literal: true
class
RemoveProjectsCiRefsProjectIdFk
<
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_refs
,
:projects
,
name:
"fk_rails_4249db8cc3"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_refs IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_refs
,
:projects
,
name:
"fk_rails_4249db8cc3"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_refs
,
:projects
,
name:
"fk_rails_4249db8cc3"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220124214131
0 → 100644
View file @
3383b327
af60c6df0fb178a4820ea8cb40b402178da7fb4b6ebeabb8739dc45b96225f89
\ No newline at end of file
db/structure.sql
View file @
3383b327
...
...
@@ -30422,9 +30422,6 @@ ALTER TABLE ONLY geo_node_namespace_links
ALTER TABLE ONLY epic_issues
ADD CONSTRAINT fk_rails_4209981af6 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_refs
ADD CONSTRAINT fk_rails_4249db8cc3 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_resources
ADD CONSTRAINT fk_rails_430336af2d FOREIGN KEY (resource_group_id) REFERENCES ci_resource_groups(id) ON DELETE CASCADE;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
3383b327
...
...
@@ -138,6 +138,10 @@ merge_trains:
-
table
:
ci_pipelines
column
:
pipeline_id
on_delete
:
async_nullify
ci_refs
:
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_group_variables
:
-
table
:
namespaces
column
:
group_id
...
...
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
3383b327
...
...
@@ -28,7 +28,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_pipelines.merge_request_id
ci_pipelines.project_id
ci_project_monthly_usages.project_id
ci_refs.project_id
ci_resource_groups.project_id
ci_runner_namespaces.namespace_id
ci_runner_projects.project_id
...
...
spec/models/ci/ref_spec.rb
View file @
3383b327
...
...
@@ -231,4 +231,11 @@ RSpec.describe Ci::Ref do
it_behaves_like
'no-op'
end
end
context
'loose foreign key on ci_refs.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_ref
,
project:
parent
)
}
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