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
f5feec0e
Commit
f5feec0e
authored
Jan 21, 2022
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_variables to projects for LFK
Swaps FK for ci_variables.project_id to projects Changelog: changed
parent
ea0d8ca9
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
4 deletions
+31
-4
db/post_migrate/20220121221651_remove_projects_ci_variables_project_id_fk.rb
...20121221651_remove_projects_ci_variables_project_id_fk.rb
+19
-0
db/schema_migrations/20220121221651
db/schema_migrations/20220121221651
+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/variable_spec.rb
spec/models/ci/variable_spec.rb
+7
-0
No files found.
db/post_migrate/20220121221651_remove_projects_ci_variables_project_id_fk.rb
0 → 100644
View file @
f5feec0e
# frozen_string_literal: true
class
RemoveProjectsCiVariablesProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
return
unless
foreign_key_exists?
(
:ci_variables
,
:projects
,
name:
"fk_ada5eb64b3"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_variables IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_variables
,
:projects
,
name:
"fk_ada5eb64b3"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_variables
,
:projects
,
name:
"fk_ada5eb64b3"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220121221651
0 → 100644
View file @
f5feec0e
a1681c1c619db7f4e7e5a760cee7d06a931aa1f02dccfce46be81d75a03ce8ac
\ No newline at end of file
db/structure.sql
View file @
f5feec0e
...
...
@@ -29696,9 +29696,6 @@ ALTER TABLE ONLY member_tasks
ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_ad525e1f87 FOREIGN KEY (merge_user_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_variables
ADD CONSTRAINT fk_ada5eb64b3 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY merge_request_metrics
ADD CONSTRAINT fk_ae440388cc FOREIGN KEY (latest_closed_by_id) REFERENCES users(id) ON DELETE SET NULL;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
f5feec0e
...
...
@@ -27,6 +27,10 @@ clusters_applications_runners:
-
table
:
ci_runners
column
:
runner_id
on_delete
:
async_nullify
ci_variables
:
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_job_token_project_scope_links
:
-
table
:
users
column
:
added_by_id
...
...
spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb
View file @
f5feec0e
...
...
@@ -40,7 +40,6 @@ RSpec.describe 'cross-database foreign keys' do
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
external_pull_requests.project_id
vulnerability_feedback.pipeline_id
...
...
spec/models/ci/variable_spec.rb
View file @
f5feec0e
...
...
@@ -44,4 +44,11 @@ RSpec.describe Ci::Variable do
end
end
end
context
'loose foreign key on ci_variables.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_variable
,
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