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
82dcb0a8
Commit
82dcb0a8
authored
Jan 05, 2022
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify post-deployment migration for loose foreign key process
parent
d96277ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
doc/development/database/loose_foreign_keys.md
doc/development/database/loose_foreign_keys.md
+13
-7
No files found.
doc/development/database/loose_foreign_keys.md
View file @
82dcb0a8
...
...
@@ -89,9 +89,10 @@ ci_pipelines:
### Track record changes
To know about deletions in the
`projects`
table, configure a
`DELETE`
trigger using a database
migration (post-migration). The trigger needs to be configured only once. If the model already has
at least one
`loose_foreign_key`
definition, then this step can be skipped:
To know about deletions in the
`projects`
table, configure a
`DELETE`
trigger
using a
[
post-deployment migration
](
../post_deployment_migrations.md
)
. The
trigger needs to be configured only once. If the model already has at least one
`loose_foreign_key`
definition, then this step can be skipped:
```
ruby
class
TrackProjectRecordChanges
<
Gitlab
::
Database
::
Migration
[
1.0
]
...
...
@@ -122,15 +123,20 @@ REFERENCES projects(id)
ON
DELETE
CASCADE
;
```
The migration should run after the
`DELETE`
trigger is installed. If the foreign key is deleted
earlier, there is a good chance of introducing data inconsistency which needs manual cleanup:
The migration must run after the
`DELETE`
trigger is installed and the loose
foreign key definition is deployed. As such, it must be a
[
post-deployment
migration
](
../post_deployment_migrations.md
)
dated after the migration for the
trigger. If the foreign key is deleted earlier, there is a good chance of
introducing data inconsistency which needs manual cleanup:
```
ruby
class
RemoveProjectsCiPipelineFk
<
Gitlab
::
Database
::
Migration
[
1.0
]
enable_lock_retries
!
disable_ddl_transaction
!
def
up
remove_foreign_key_if_exists
(
:ci_pipelines
,
:projects
,
name:
"fk_86635dbd80"
)
with_lock_retries
do
remove_foreign_key_if_exists
(
:ci_pipelines
,
:projects
,
name:
"fk_86635dbd80"
)
end
end
def
down
...
...
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