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
9f2dc374
Commit
9f2dc374
authored
Jan 19, 2022
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_sources_pipelines to projects for LFK
Removes FK for ci_sources_pipelines to projects Changelog: changed
parent
6eec8e90
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
4 deletions
+29
-4
db/post_migrate/20220119143130_remove_projects_ci_sources_pipelines_source_project_id_fk.rb
...ove_projects_ci_sources_pipelines_source_project_id_fk.rb
+17
-0
db/schema_migrations/20220119143130
db/schema_migrations/20220119143130
+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/sources/pipeline_spec.rb
spec/models/ci/sources/pipeline_spec.rb
+7
-0
No files found.
db/post_migrate/20220119143130_remove_projects_ci_sources_pipelines_source_project_id_fk.rb
0 → 100644
View file @
9f2dc374
# frozen_string_literal: true
class
RemoveProjectsCiSourcesPipelinesSourceProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
with_lock_retries
do
execute
(
'LOCK projects, ci_sources_pipelines IN ACCESS EXCLUSIVE MODE'
)
remove_foreign_key_if_exists
(
:ci_sources_pipelines
,
:projects
,
name:
"fk_acd9737679"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_sources_pipelines
,
:projects
,
name:
"fk_acd9737679"
,
column: :source_project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220119143130
0 → 100644
View file @
9f2dc374
a375f82fe0c1ef87aa6abb2142387b852b135be6e2158fd8456b23dc9bcf2a0e
\ No newline at end of file
db/structure.sql
View file @
9f2dc374
...
...
@@ -29692,9 +29692,6 @@ ALTER TABLE ONLY boards
ALTER TABLE ONLY member_tasks
ADD CONSTRAINT fk_ab636303dd FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_sources_pipelines
ADD CONSTRAINT fk_acd9737679 FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_ad525e1f87 FOREIGN KEY (merge_user_id) REFERENCES users(id) ON DELETE SET NULL;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
9f2dc374
...
...
@@ -158,3 +158,7 @@ ci_pipeline_artifacts:
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_sources_pipelines
:
-
table
:
projects
column
:
source_project_id
on_delete
:
async_delete
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
9f2dc374
...
...
@@ -34,7 +34,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_runner_projects.project_id
ci_running_builds.project_id
ci_sources_pipelines.project_id
ci_sources_pipelines.source_project_id
ci_sources_projects.source_project_id
ci_stages.project_id
ci_subscriptions_projects.downstream_project_id
...
...
spec/models/ci/sources/pipeline_spec.rb
View file @
9f2dc374
...
...
@@ -17,4 +17,11 @@ RSpec.describe Ci::Sources::Pipeline do
it
{
is_expected
.
to
validate_presence_of
(
:source_project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source_job
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source_pipeline
)
}
context
'loose foreign key on ci_sources_pipelines.source_project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_sources_pipeline
,
source_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