BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b33b7be5
Unverified
Commit
b33b7be5
authored
Jun 13, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle NULL migration errors in migration helpers
This ensures that whenever changing the NULL constraint of a column fails we still drop the column.
parent
65df6bcb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+2
-2
migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+13
-0
No files found.
lib/gitlab/database/migration_helpers.rb
View file @
b33b7be5
...
...
@@ -126,6 +126,8 @@ module Gitlab
begin
transaction
do
update_column_in_batches
(
table
,
column
,
default
)
change_column_null
(
table
,
column
,
false
)
unless
allow_null
end
# We want to rescue _all_ exceptions here, even those that don't inherit
# from StandardError.
...
...
@@ -134,8 +136,6 @@ module Gitlab
raise
error
end
change_column_null
(
table
,
column
,
false
)
unless
allow_null
end
end
end
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
b33b7be5
...
...
@@ -120,6 +120,19 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
model
.
add_column_with_default
(
:projects
,
:foo
,
:integer
,
default:
10
)
end
.
to
raise_error
(
RuntimeError
)
end
it
'removes the added column whenever changing a column NULL constraint fails'
do
expect
(
model
).
to
receive
(
:change_column_null
).
with
(
:projects
,
:foo
,
false
).
and_raise
(
RuntimeError
)
expect
(
model
).
to
receive
(
:remove_column
).
with
(
:projects
,
:foo
)
expect
do
model
.
add_column_with_default
(
:projects
,
:foo
,
:integer
,
default:
10
)
end
.
to
raise_error
(
RuntimeError
)
end
end
context
'inside a transaction'
do
...
...
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