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
2dafb6f9
Commit
2dafb6f9
authored
Aug 28, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create foreign key constraints in seperate migrations
To comply with the style guides at Gitlab.
parent
94d5d2bb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
3 deletions
+43
-3
db/migrate/20200825084819_create_security_findings_table.rb
db/migrate/20200825084819_create_security_findings_table.rb
+3
-3
db/migrate/20200828155134_add_foreign_key_on_scan_id_to_security_scans.rb
...828155134_add_foreign_key_on_scan_id_to_security_scans.rb
+19
-0
db/migrate/20200828155205_add_foreign_key_on_scanner_id_to_vulnerability_scanners.rb
...dd_foreign_key_on_scanner_id_to_vulnerability_scanners.rb
+19
-0
db/schema_migrations/20200828155134
db/schema_migrations/20200828155134
+1
-0
db/schema_migrations/20200828155205
db/schema_migrations/20200828155205
+1
-0
No files found.
db/migrate/20200825084819_create_security_findings_table.rb
View file @
2dafb6f9
...
@@ -8,9 +8,9 @@ class CreateSecurityFindingsTable < ActiveRecord::Migration[6.0]
...
@@ -8,9 +8,9 @@ class CreateSecurityFindingsTable < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
disable_ddl_transaction!
def
up
def
up
create_table
:security_findings
,
i
d: :bigserial
do
|
t
|
create_table
:security_findings
,
i
f_not_exists:
true
do
|
t
|
t
.
references
:scan
,
null:
false
,
foreign_key:
{
to_table: :security_scans
,
on_delete: :cascade
}
t
.
references
:scan
,
null:
false
t
.
references
:scanner
,
null:
false
,
foreign_key:
{
to_table: :vulnerability_scanners
,
on_delete: :cascade
}
t
.
references
:scanner
,
null:
false
t
.
integer
:severity
,
limit:
2
,
index:
true
,
null:
false
t
.
integer
:severity
,
limit:
2
,
index:
true
,
null:
false
t
.
integer
:confidence
,
limit:
2
,
index:
true
,
null:
false
t
.
integer
:confidence
,
limit:
2
,
index:
true
,
null:
false
t
.
text
:project_fingerprint
,
index:
true
,
null:
false
t
.
text
:project_fingerprint
,
index:
true
,
null:
false
...
...
db/migrate/20200828155134_add_foreign_key_on_scan_id_to_security_scans.rb
0 → 100644
View file @
2dafb6f9
# frozen_string_literal: true
class
AddForeignKeyOnScanIdToSecurityScans
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
with_lock_retries
do
add_foreign_key
:security_findings
,
:security_scans
,
column: :scan_id
,
on_delete: :cascade
# rubocop:disable Migration/AddConcurrentForeignKey
end
end
def
down
with_lock_retries
do
remove_foreign_key
:security_findings
,
column: :scan_id
end
end
end
db/migrate/20200828155205_add_foreign_key_on_scanner_id_to_vulnerability_scanners.rb
0 → 100644
View file @
2dafb6f9
# frozen_string_literal: true
class
AddForeignKeyOnScannerIdToVulnerabilityScanners
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
with_lock_retries
do
add_foreign_key
:security_findings
,
:vulnerability_scanners
,
column: :scanner_id
,
on_delete: :cascade
# rubocop:disable Migration/AddConcurrentForeignKey
end
end
def
down
with_lock_retries
do
remove_foreign_key
:security_findings
,
column: :scanner_id
end
end
end
db/schema_migrations/20200828155134
0 → 100644
View file @
2dafb6f9
b3ee994231a8da694dbcda227b37e19a2112be666648d918425b064ec19d239e
\ No newline at end of file
db/schema_migrations/20200828155205
0 → 100644
View file @
2dafb6f9
b575558752206149171a05231e4167e1ac3e1295f76d800edfe3d61c1b996b52
\ No newline at end of file
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