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
dbc0fb73
Commit
dbc0fb73
authored
Jan 21, 2022
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap FK ci_stages to projects for LFK
Swaps FK for ci_stages.project_id to projects Changelog: changed
parent
f62b6a67
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
3 deletions
+32
-3
db/post_migrate/20220121214752_remove_projects_ci_stages_project_id_fk.rb
...20220121214752_remove_projects_ci_stages_project_id_fk.rb
+20
-0
db/schema_migrations/20220121214752
db/schema_migrations/20220121214752
+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/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+7
-0
No files found.
db/post_migrate/20220121214752_remove_projects_ci_stages_project_id_fk.rb
0 → 100644
View file @
dbc0fb73
# frozen_string_literal: true
class
RemoveProjectsCiStagesProjectIdFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
def
up
return
if
Gitlab
.
com?
# unsafe migration, skip on GitLab.com due to https://gitlab.com/groups/gitlab-org/-/epics/7249#note_819625526
return
unless
foreign_key_exists?
(
:ci_stages
,
:projects
,
name:
"fk_2360681d1d"
)
with_lock_retries
do
execute
(
'LOCK projects, ci_stages IN ACCESS EXCLUSIVE MODE'
)
if
transaction_open?
remove_foreign_key_if_exists
(
:ci_stages
,
:projects
,
name:
"fk_2360681d1d"
)
end
end
def
down
add_concurrent_foreign_key
(
:ci_stages
,
:projects
,
name:
"fk_2360681d1d"
,
column: :project_id
,
target_column: :id
,
on_delete: :cascade
)
end
end
db/schema_migrations/20220121214752
0 → 100644
View file @
dbc0fb73
c56983a489b56eb6b4a5cd5ae6947a322fd58b8e96bcdee1e38634d99727c432
\ No newline at end of file
db/structure.sql
View file @
dbc0fb73
...
...
@@ -29261,9 +29261,6 @@ ALTER TABLE ONLY users_star_projects
ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_2358b75436 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL;
ALTER TABLE ONLY ci_stages
ADD CONSTRAINT fk_2360681d1d FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY import_failures
ADD CONSTRAINT fk_24b824da43 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
lib/gitlab/database/gitlab_loose_foreign_keys.yml
View file @
dbc0fb73
...
...
@@ -191,6 +191,10 @@ ci_sources_pipelines:
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_stages
:
-
table
:
projects
column
:
project_id
on_delete
:
async_delete
ci_triggers
:
-
table
:
users
column
:
owner_id
...
...
spec/models/ci/stage_spec.rb
View file @
dbc0fb73
...
...
@@ -362,4 +362,11 @@ RSpec.describe Ci::Stage, :models do
end
it_behaves_like
'manual playable stage'
,
:ci_stage_entity
context
'loose foreign key on ci_stages.project_id'
do
it_behaves_like
'cleanup by a loose foreign key'
do
let!
(
:parent
)
{
create
(
:project
)
}
let!
(
:model
)
{
create
(
:ci_stage_entity
,
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