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
3540dcc5
Commit
3540dcc5
authored
Jan 19, 2022
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_triggers to users for LFK
Removes FK for ci_triggers to users Changelog: changed
parent
09f545c1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
4 deletions
+29
-4
db/post_migrate/20220119144458_remove_users_ci_triggers_owner_id_fk.rb
...te/20220119144458_remove_users_ci_triggers_owner_id_fk.rb
+17
-0
db/schema_migrations/20220119144458
db/schema_migrations/20220119144458
+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/trigger_spec.rb
spec/models/ci/trigger_spec.rb
+7
-0
No files found.
db/post_migrate/20220119144458_remove_users_ci_triggers_owner_id_fk.rb
0 → 100644
View file @
3540dcc5
# frozen_string_literal: true
class
RemoveUsersCiTriggersOwnerIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
with_lock_retries
do
execute
(
'LOCK users, ci_triggers IN ACCESS EXCLUSIVE MODE'
)
remove_foreign_key_if_exists
(
:ci_triggers
,
:users
,
name:
"fk_e8e10d1964"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_triggers
,
:users
,
name:
"fk_e8e10d1964"
,
column: :owner_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220119144458
0 → 100644
View file @
3540dcc5
85227d2aa0e984f12362484b23554a4feb1304d055d54da40e20812f2d8c5b9e
\ No newline at end of file
db/structure.sql
View file @
3540dcc5
...
...
@@ -29930,9 +29930,6 @@ ALTER TABLE ONLY application_settings
ALTER TABLE ONLY vulnerability_statistics
ADD CONSTRAINT fk_e8b13c928f FOREIGN KEY (latest_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_triggers
ADD CONSTRAINT fk_e8e10d1964 FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE ONLY integrations
ADD CONSTRAINT fk_e8fe908a34 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
3540dcc5
...
...
@@ -162,3 +162,7 @@ ci_sources_pipelines:
-
table
:
projects
column
:
source_project_id
on_delete
:
async_delete
ci_triggers
:
-
table
:
users
column
:
owner_id
on_delete
:
async_delete
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
3540dcc5
...
...
@@ -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.owner_id
ci_triggers.project_id
ci_unit_tests.project_id
ci_variables.project_id
...
...
spec/models/ci/trigger_spec.rb
View file @
3540dcc5
...
...
@@ -61,4 +61,11 @@ RSpec.describe Ci::Trigger do
it_behaves_like
'includes Limitable concern'
do
subject
{
build
(
:ci_trigger
,
owner:
project
.
owner
,
project:
project
)
}
end
context
'loose foreign key on ci_triggers.owner_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:user
)
}
let!
(
:model
)
{
create
(
:ci_trigger
,
owner:
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