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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3bad69cc
Commit
3bad69cc
authored
Jul 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve stage_id in ci_builds foreign key migration
parent
0f30bcf1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
db/migrate/20170703102400_add_stage_id_foreign_key_to_builds.rb
...rate/20170703102400_add_stage_id_foreign_key_to_builds.rb
+21
-0
db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
...st_migrate/20170621102400_add_stage_id_index_to_builds.rb
+5
-9
No files found.
db/migrate/20170703102400_add_stage_id_foreign_key_to_builds.rb
0 → 100644
View file @
3bad69cc
class
AddStageIdForeignKeyToBuilds
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
unless
index_exists?
(
:ci_builds
,
:stage_id
)
add_concurrent_index
(
:ci_builds
,
:stage_id
)
add_concurrent_foreign_key
(
:ci_builds
,
:ci_stages
,
column: :stage_id
,
on_delete: :cascade
)
end
end
def
down
if
index_exists?
(
:ci_builds
,
:stage_id
)
remove_foreign_key
(
:ci_builds
,
column: :stage_id
)
remove_concurrent_index
(
:ci_builds
,
:stage_id
)
end
end
end
db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
View file @
3bad69cc
...
...
@@ -3,19 +3,15 @@ class AddStageIdIndexToBuilds < ActiveRecord::Migration
DOWNTIME
=
false
disable_ddl_transaction!
##
# Improved in 20170703102400_add_stage_id_foreign_key_to_builds.rb
#
def
up
unless
index_exists?
(
:ci_builds
,
:stage_id
)
add_concurrent_foreign_key
(
:ci_builds
,
:ci_stages
,
column: :stage_id
,
on_delete: :cascade
)
add_concurrent_index
(
:ci_builds
,
:stage_id
)
end
# noop
end
def
down
if
index_exists?
(
:ci_builds
,
:stage_id
)
remove_foreign_key
(
:ci_builds
,
column: :stage_id
)
remove_concurrent_index
(
:ci_builds
,
:stage_id
)
end
# noop
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