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
d9462f4d
Commit
d9462f4d
authored
Dec 17, 2018
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split migration into adding column and adding FK
parent
d2ad55fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
ee/db/migrate/20181123090058_add_parent_to_epic.rb
ee/db/migrate/20181123090058_add_parent_to_epic.rb
+2
-14
ee/db/migrate/20181123100058_add_parent_epic_fk.rb
ee/db/migrate/20181123100058_add_parent_epic_fk.rb
+21
-0
No files found.
ee/db/migrate/20181123090058_add_parent_to_epic.rb
View file @
d9462f4d
...
...
@@ -7,23 +7,11 @@ class AddParentToEpic < ActiveRecord::Migration[5.0]
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column
:epics
,
:parent_id
,
:integer
unless
parent_id_exists?
add_concurrent_foreign_key
:epics
,
:epics
,
column: :parent_id
,
on_delete: :cascade
add_concurrent_index
:epics
,
:parent_id
add_column
:epics
,
:parent_id
,
:integer
end
def
down
remove_foreign_key_without_error
(
:epics
,
column: :parent_id
)
remove_concurrent_index
(
:epics
,
:parent_id
)
remove_column
(
:epics
,
:parent_id
)
if
parent_id_exists?
end
private
def
parent_id_exists?
column_exists?
(
:epics
,
:parent_id
)
remove_column
:epics
,
:parent_id
end
end
ee/db/migrate/20181123100058_add_parent_epic_fk.rb
0 → 100644
View file @
d9462f4d
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddParentEpicFk
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_foreign_key
:epics
,
:epics
,
column: :parent_id
,
on_delete: :cascade
add_concurrent_index
:epics
,
:parent_id
end
def
down
remove_foreign_key
:epics
,
column: :parent_id
remove_concurrent_index
:epics
,
:parent_id
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