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
485d3c9d
Commit
485d3c9d
authored
Apr 20, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we delete on cascade for insights
parent
bc2b3171
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
db/schema.rb
db/schema.rb
+2
-2
ee/db/migrate/20190415172035_update_insights_foreign_keys.rb
ee/db/migrate/20190415172035_update_insights_foreign_keys.rb
+25
-0
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+6
-0
No files found.
db/schema.rb
View file @
485d3c9d
...
@@ -3605,8 +3605,8 @@ ActiveRecord::Schema.define(version: 20190506135400) do
...
@@ -3605,8 +3605,8 @@ ActiveRecord::Schema.define(version: 20190506135400) do
add_foreign_key
"identities"
,
"saml_providers"
,
name:
"fk_aade90f0fc"
,
on_delete: :cascade
add_foreign_key
"identities"
,
"saml_providers"
,
name:
"fk_aade90f0fc"
,
on_delete: :cascade
add_foreign_key
"import_export_uploads"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"import_export_uploads"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"index_statuses"
,
"projects"
,
name:
"fk_74b2492545"
,
on_delete: :cascade
add_foreign_key
"index_statuses"
,
"projects"
,
name:
"fk_74b2492545"
,
on_delete: :cascade
add_foreign_key
"insights"
,
"namespaces"
add_foreign_key
"insights"
,
"namespaces"
,
on_delete: :cascade
add_foreign_key
"insights"
,
"projects"
add_foreign_key
"insights"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"namespaces"
,
name:
"fk_162941d509"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"namespaces"
,
name:
"fk_162941d509"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"issues"
,
name:
"fk_b7d881734a"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"issues"
,
name:
"fk_b7d881734a"
,
on_delete: :cascade
...
...
ee/db/migrate/20190415172035_update_insights_foreign_keys.rb
0 → 100644
View file @
485d3c9d
# frozen_string_literal: true
# rubocop: disable Migration/AddConcurrentForeignKey
class
UpdateInsightsForeignKeys
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
remove_foreign_key_if_exists
(
:insights
,
column: :project_id
)
add_foreign_key
(
:insights
,
:projects
,
column: :project_id
,
on_delete: :cascade
)
remove_foreign_key_if_exists
(
:insights
,
column: :namespace_id
)
add_foreign_key
(
:insights
,
:namespaces
,
column: :namespace_id
,
on_delete: :cascade
)
end
def
down
remove_foreign_key_if_exists
(
:insights
,
column: :namespace_id
)
add_foreign_key
(
:insights
,
:namespaces
,
column: :namespace_id
)
remove_foreign_key_if_exists
(
:insights
,
column: :project_id
)
add_foreign_key
(
:insights
,
:projects
,
column: :project_id
)
end
end
lib/gitlab/database/migration_helpers.rb
View file @
485d3c9d
...
@@ -905,6 +905,12 @@ module Gitlab
...
@@ -905,6 +905,12 @@ module Gitlab
end
end
end
end
def
remove_foreign_key_if_exists
(
*
args
)
if
foreign_key_exists?
(
args
)
remove_foreign_key
(
args
)
end
end
def
remove_foreign_key_without_error
(
*
args
)
def
remove_foreign_key_without_error
(
*
args
)
remove_foreign_key
(
*
args
)
remove_foreign_key
(
*
args
)
rescue
ArgumentError
rescue
ArgumentError
...
...
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