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
885d63d9
Commit
885d63d9
authored
Jun 21, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix adding/removing foreign keys on MySQL
parent
6b9608e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
4 deletions
+3
-4
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
+0
-4
db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
...grate/20170526185901_remove_stage_id_index_from_builds.rb
+1
-0
db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
...st_migrate/20170621102400_add_stage_id_index_to_builds.rb
+2
-0
No files found.
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
View file @
885d63d9
...
...
@@ -3,15 +3,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column
:ci_builds
,
:stage_id
,
:integer
add_concurrent_foreign_key
:ci_builds
,
:ci_stages
,
column: :stage_id
,
on_delete: :cascade
end
def
down
remove_foreign_key
:ci_builds
,
column: :stage_id
remove_column
:ci_builds
,
:stage_id
,
:integer
end
end
db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
View file @
885d63d9
...
...
@@ -7,6 +7,7 @@ class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration
def
up
if
index_exists?
(
:ci_builds
,
:stage_id
)
remove_foreign_key
(
:ci_builds
,
column: :stage_id
)
remove_concurrent_index
(
:ci_builds
,
:stage_id
)
end
end
...
...
db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
View file @
885d63d9
...
...
@@ -7,12 +7,14 @@ class AddStageIdIndexToBuilds < ActiveRecord::Migration
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
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
...
...
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