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
343e42b6
Commit
343e42b6
authored
Jan 20, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve migrations readability
parent
574b9c67
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
21 deletions
+33
-21
db/migrate/20170118194941_convert_application_settings_repository_size_limit_to_bytes.rb
...rt_application_settings_repository_size_limit_to_bytes.rb
+11
-7
db/migrate/20170118200338_convert_projects_repository_size_limit_to_bytes.rb
...200338_convert_projects_repository_size_limit_to_bytes.rb
+11
-7
db/migrate/20170118200412_convert_namespaces_repository_size_limit_to_bytes.rb
...0412_convert_namespaces_repository_size_limit_to_bytes.rb
+11
-7
No files found.
db/migrate/20170118194941_convert_application_settings_repository_size_limit_to_bytes.rb
View file @
343e42b6
...
@@ -10,14 +10,16 @@ class ConvertApplicationSettingsRepositorySizeLimitToBytes < ActiveRecord::Migra
...
@@ -10,14 +10,16 @@ class ConvertApplicationSettingsRepositorySizeLimitToBytes < ActiveRecord::Migra
add_column
:application_settings
,
:repository_size_limit
,
:integer
,
default:
0
,
limit:
8
add_column
:application_settings
,
:repository_size_limit
,
:integer
,
default:
0
,
limit:
8
end
end
bigint_expression
=
if
Gitlab
::
Database
.
postgresql?
bigint_string
=
if
Gitlab
::
Database
.
postgresql?
'repository_size_limit_mb::bigint * 1024 * 1024'
'repository_size_limit_mb::bigint * 1024 * 1024'
else
else
'repository_size_limit_mb * 1024 * 1024'
'repository_size_limit_mb * 1024 * 1024'
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_string
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:application_settings
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_expression
)
)
do
|
t
,
query
|
update_column_in_batches
(
:application_settings
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
end
end
...
@@ -31,8 +33,10 @@ class ConvertApplicationSettingsRepositorySizeLimitToBytes < ActiveRecord::Migra
...
@@ -31,8 +33,10 @@ class ConvertApplicationSettingsRepositorySizeLimitToBytes < ActiveRecord::Migra
add_column
:application_settings
,
:repository_size_limit
,
:integer
,
default:
0
,
limit:
nil
add_column
:application_settings
,
:repository_size_limit
,
:integer
,
default:
0
,
limit:
nil
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:application_settings
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
)
do
|
t
,
query
|
update_column_in_batches
(
:application_settings
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
end
end
...
...
db/migrate/20170118200338_convert_projects_repository_size_limit_to_bytes.rb
View file @
343e42b6
...
@@ -13,14 +13,16 @@ class ConvertProjectsRepositorySizeLimitToBytes < ActiveRecord::Migration
...
@@ -13,14 +13,16 @@ class ConvertProjectsRepositorySizeLimitToBytes < ActiveRecord::Migration
add_column
:projects
,
:repository_size_limit
,
:integer
,
limit:
8
add_column
:projects
,
:repository_size_limit
,
:integer
,
limit:
8
end
end
bigint_expression
=
if
Gitlab
::
Database
.
postgresql?
bigint_string
=
if
Gitlab
::
Database
.
postgresql?
'repository_size_limit_mb::bigint * 1024 * 1024'
'repository_size_limit_mb::bigint * 1024 * 1024'
else
else
'repository_size_limit_mb * 1024 * 1024'
'repository_size_limit_mb * 1024 * 1024'
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_string
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:projects
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_expression
)
)
do
|
t
,
query
|
update_column_in_batches
(
:projects
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
end
end
...
@@ -34,8 +36,10 @@ class ConvertProjectsRepositorySizeLimitToBytes < ActiveRecord::Migration
...
@@ -34,8 +36,10 @@ class ConvertProjectsRepositorySizeLimitToBytes < ActiveRecord::Migration
add_column
:projects
,
:repository_size_limit
,
:integer
,
limit:
nil
add_column
:projects
,
:repository_size_limit
,
:integer
,
limit:
nil
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:projects
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
)
do
|
t
,
query
|
update_column_in_batches
(
:projects
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
end
end
...
...
db/migrate/20170118200412_convert_namespaces_repository_size_limit_to_bytes.rb
View file @
343e42b6
...
@@ -13,14 +13,16 @@ class ConvertNamespacesRepositorySizeLimitToBytes < ActiveRecord::Migration
...
@@ -13,14 +13,16 @@ class ConvertNamespacesRepositorySizeLimitToBytes < ActiveRecord::Migration
add_column
:namespaces
,
:repository_size_limit
,
:integer
,
limit:
8
add_column
:namespaces
,
:repository_size_limit
,
:integer
,
limit:
8
end
end
bigint_expression
=
if
Gitlab
::
Database
.
postgresql?
bigint_string
=
if
Gitlab
::
Database
.
postgresql?
'repository_size_limit_mb::bigint * 1024 * 1024'
'repository_size_limit_mb::bigint * 1024 * 1024'
else
else
'repository_size_limit_mb * 1024 * 1024'
'repository_size_limit_mb * 1024 * 1024'
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_string
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:namespaces
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
bigint_expression
)
)
do
|
t
,
query
|
update_column_in_batches
(
:namespaces
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_mb
].
not_eq
(
nil
))
end
end
...
@@ -34,8 +36,10 @@ class ConvertNamespacesRepositorySizeLimitToBytes < ActiveRecord::Migration
...
@@ -34,8 +36,10 @@ class ConvertNamespacesRepositorySizeLimitToBytes < ActiveRecord::Migration
add_column
:namespaces
,
:repository_size_limit
,
:integer
,
limit:
nil
add_column
:namespaces
,
:repository_size_limit
,
:integer
,
limit:
nil
end
end
sql_expression
=
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
connection
.
transaction
do
connection
.
transaction
do
update_column_in_batches
(
:namespaces
,
:repository_size_limit
,
Arel
::
Nodes
::
SqlLiteral
.
new
(
'repository_size_limit_bytes / 1024 / 1024'
)
)
do
|
t
,
query
|
update_column_in_batches
(
:namespaces
,
:repository_size_limit
,
sql_expression
)
do
|
t
,
query
|
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
query
.
where
(
t
[
:repository_size_limit_bytes
].
not_eq
(
nil
))
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