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
914ecdff
Commit
914ecdff
authored
Dec 23, 2020
by
Vladimir Shushlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to pass limit to undo_cleanup_concurrent_column_type_change
parent
d9958bf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+6
-4
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+7
-4
No files found.
lib/gitlab/database/migration_helpers.rb
View file @
914ecdff
...
...
@@ -578,7 +578,7 @@ module Gitlab
# type_cast_function - Required if the conversion back to the original type is not automatic
# batch_column_name - option for tables without a primary key, in this case
# another unique integer column can be used. Example: :user_id
def
undo_cleanup_concurrent_column_type_change
(
table
,
column
,
old_type
,
type_cast_function:
nil
,
batch_column_name: :id
)
def
undo_cleanup_concurrent_column_type_change
(
table
,
column
,
old_type
,
type_cast_function:
nil
,
batch_column_name: :id
,
limit:
nil
)
temp_column
=
"
#{
column
}
_for_type_change"
# Using a descriptive name that includes orinal column's name risks
...
...
@@ -604,7 +604,8 @@ module Gitlab
temp_undo_cleanup_column
,
type:
old_type
,
batch_column_name:
batch_column_name
,
type_cast_function:
type_cast_function
type_cast_function:
type_cast_function
,
limit:
limit
)
transaction
do
...
...
@@ -1489,12 +1490,13 @@ into similar problems in the future (e.g. when new tables are created).
"ON DELETE
#{
on_delete
.
upcase
}
"
end
def
create_column_from
(
table
,
old
,
new
,
type:
nil
,
batch_column_name: :id
,
type_cast_function:
nil
)
def
create_column_from
(
table
,
old
,
new
,
type:
nil
,
batch_column_name: :id
,
type_cast_function:
nil
,
limit:
nil
)
old_col
=
column_for
(
table
,
old
)
new_type
=
type
||
old_col
.
type
new_limit
=
limit
||
old_col
.
limit
add_column
(
table
,
new
,
new_type
,
limit:
old_col
.
limit
,
limit:
new_
limit
,
precision:
old_col
.
precision
,
scale:
old_col
.
scale
)
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
914ecdff
...
...
@@ -992,7 +992,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
temp_undo_cleanup_column
,
type: :string
,
batch_column_name: :id
,
type_cast_function:
nil
type_cast_function:
nil
,
limit:
nil
).
and_return
(
true
)
expect
(
model
).
to
receive
(
:rename_column
)
...
...
@@ -1007,7 +1008,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
model
.
undo_cleanup_concurrent_column_type_change
(
:users
,
:old
,
:string
)
end
it
'passes the type_cast_function
and batch_column_name
'
do
it
'passes the type_cast_function
, batch_column_name and limit
'
do
expect
(
model
).
to
receive
(
:column_exists?
).
with
(
:users
,
:other_batch_column
).
and_return
(
true
)
expect
(
model
).
to
receive
(
:check_trigger_permissions!
).
with
(
:users
)
...
...
@@ -1017,7 +1018,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
temp_undo_cleanup_column
,
type: :string
,
batch_column_name: :other_batch_column
,
type_cast_function: :custom_type_cast_function
type_cast_function: :custom_type_cast_function
,
limit:
8
).
and_return
(
true
)
expect
(
model
).
to
receive
(
:rename_column
)
...
...
@@ -1034,7 +1036,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
:old
,
:string
,
type_cast_function: :custom_type_cast_function
,
batch_column_name: :other_batch_column
batch_column_name: :other_batch_column
,
limit:
8
)
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