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
6f1546ce
Commit
6f1546ce
authored
Jan 24, 2022
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_triggers to projects for LFK
Swaps FK for ci_triggers.project_id to projects Changelog: changed
parent
54756729
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
4 deletions
+30
-4
db/post_migrate/20220124151456_remove_projects_ci_triggers_project_id_fk.rb
...220124151456_remove_projects_ci_triggers_project_id_fk.rb
+19
-0
db/schema_migrations/20220124151456
db/schema_migrations/20220124151456
+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/trigger_spec.rb
spec/models/ci/trigger_spec.rb
+7
-0
No files found.
db/post_migrate/20220124151456_remove_projects_ci_triggers_project_id_fk.rb
0 → 100644
View file @
6f1546ce
# frozen_string_literal: true
class
RemoveProjectsCiTriggersProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
return
unless
foreign_key_exists?
(
:ci_triggers
,
:projects
,
name:
"fk_e3e63f966e"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_triggers IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_triggers
,
:projects
,
name:
"fk_e3e63f966e"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_triggers
,
:projects
,
name:
"fk_e3e63f966e"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220124151456
0 → 100644
View file @
6f1546ce
5ec73b28adb027a4462ec9b268ef9c505e281f1afedce3c592d431cd90808dac
\ No newline at end of file
db/structure.sql
View file @
6f1546ce
...
...
@@ -29906,9 +29906,6 @@ ALTER TABLE ONLY ci_builds_metadata
ALTER TABLE ONLY gitlab_subscriptions
ADD CONSTRAINT fk_e2595d00a1 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_triggers
ADD CONSTRAINT fk_e3e63f966e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_e719a85f8a FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
6f1546ce
...
...
@@ -170,3 +170,6 @@ ci_triggers:
-
table
:
users
column
:
owner_id
on_delete
:
async_delete
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
6f1546ce
...
...
@@ -38,7 +38,6 @@ RSpec.describe 'cross-database foreign keys' do
ci_stages.project_id
ci_subscriptions_projects.downstream_project_id
ci_subscriptions_projects.upstream_project_id
ci_triggers.project_id
ci_unit_tests.project_id
ci_variables.project_id
dast_site_profiles_pipelines.ci_pipeline_id
...
...
spec/models/ci/trigger_spec.rb
View file @
6f1546ce
...
...
@@ -68,4 +68,11 @@ RSpec.describe Ci::Trigger do
let!
(
:model
)
{
create
(
:ci_trigger
,
owner:
parent
)
}
end
end
context
'loose foreign key on ci_triggers.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_trigger
,
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