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
1716da95
Commit
1716da95
authored
Jan 26, 2022
by
Douglas Barbosa Alexandre
Committed by
Adam Hegyi
Jan 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_pipelines to projects for LFK
Swaps FK for ci_pipelines.project_id to projects Changelog: changed
parent
e14b7cce
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
4 deletions
+30
-4
db/post_migrate/20220126210657_remove_projects_ci_pipelines_project_id_fk.rb
...20126210657_remove_projects_ci_pipelines_project_id_fk.rb
+19
-0
db/schema_migrations/20220126210657
db/schema_migrations/20220126210657
+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/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+7
-0
No files found.
db/post_migrate/20220126210657_remove_projects_ci_pipelines_project_id_fk.rb
0 → 100644
View file @
1716da95
# frozen_string_literal: true
class
RemoveProjectsCiPipelinesProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
return
unless
foreign_key_exists?
(
:ci_pipelines
,
:projects
,
name:
"fk_86635dbd80"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_pipelines IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_pipelines
,
:projects
,
name:
"fk_86635dbd80"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_pipelines
,
:projects
,
name:
"fk_86635dbd80"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220126210657
0 → 100644
View file @
1716da95
853209f3babe2856481591790d9bb67145c4c0c919ed4d8365bb8d498e4f6b8e
\ No newline at end of file
db/structure.sql
View file @
1716da95
...
...
@@ -29544,9 +29544,6 @@ ALTER TABLE ONLY merge_request_diffs
ALTER TABLE ONLY requirements
ADD CONSTRAINT fk_85044baef0 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_pipelines
ADD CONSTRAINT fk_86635dbd80 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY geo_event_log
ADD CONSTRAINT fk_86c84214ec FOREIGN KEY (repository_renamed_event_id) REFERENCES geo_repository_renamed_events(id) ON DELETE CASCADE;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
1716da95
...
...
@@ -112,6 +112,9 @@ ci_pipelines:
-
table
:
users
column
:
user_id
on_delete
:
async_nullify
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_project_mirrors
:
-
table
:
projects
column
:
project_id
...
...
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
1716da95
...
...
@@ -19,7 +19,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_pending_builds.namespace_id
ci_pending_builds.project_id
ci_pipeline_schedules.owner_id
ci_pipelines.project_id
ci_resource_groups.project_id
ci_runner_namespaces.namespace_id
ci_running_builds.project_id
...
...
spec/models/ci/pipeline_spec.rb
View file @
1716da95
...
...
@@ -4731,4 +4731,11 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let!
(
:model
)
{
create
(
:ci_pipeline
,
merge_request:
parent
)
}
end
end
context
'loose foreign key on ci_pipelines.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_pipeline
,
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