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
Léo-Paul Géneau
gitlab-ce
Commits
a366fa09
Commit
a366fa09
authored
Apr 27, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for fill_file_store migration
parent
4b85b4dc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
6 deletions
+49
-6
db/post_migrate/20180424151928_fill_file_store.rb
db/post_migrate/20180424151928_fill_file_store.rb
+0
-0
lib/gitlab/background_migration/fill_file_store_job_artifact.rb
...tlab/background_migration/fill_file_store_job_artifact.rb
+2
-2
lib/gitlab/background_migration/fill_file_store_lfs_object.rb
...gitlab/background_migration/fill_file_store_lfs_object.rb
+2
-2
lib/gitlab/background_migration/fill_file_store_upload.rb
lib/gitlab/background_migration/fill_file_store_upload.rb
+2
-2
spec/migrations/fill_file_store_spec.rb
spec/migrations/fill_file_store_spec.rb
+43
-0
No files found.
db/post_migrate/20180424151928_fill_file_store.rb
.rb
→
db/post_migrate/20180424151928_fill_file_store.rb
View file @
a366fa09
File moved
lib/gitlab/background_migration/fill_file_store_job_artifact.rb
View file @
a366fa09
...
@@ -10,8 +10,8 @@ module Gitlab
...
@@ -10,8 +10,8 @@ module Gitlab
end
end
def
perform
(
start_id
,
stop_id
)
def
perform
(
start_id
,
stop_id
)
FillFileStoreJobArtifact
::
JobArtifact
Gitlab
::
BackgroundMigration
::
FillFileStoreJobArtifact
::
JobArtifact
.
where
(
'file_store
=
NULL'
)
.
where
(
'file_store
is
NULL'
)
.
where
(
id:
(
start_id
..
stop_id
))
.
where
(
id:
(
start_id
..
stop_id
))
.
update_all
(
file_store:
1
)
.
update_all
(
file_store:
1
)
end
end
...
...
lib/gitlab/background_migration/fill_file_store_lfs_object.rb
View file @
a366fa09
...
@@ -10,8 +10,8 @@ module Gitlab
...
@@ -10,8 +10,8 @@ module Gitlab
end
end
def
perform
(
start_id
,
stop_id
)
def
perform
(
start_id
,
stop_id
)
FillFileStoreLfsObject
::
LfsObject
Gitlab
::
BackgroundMigration
::
FillFileStoreLfsObject
::
LfsObject
.
where
(
'file_store
=
NULL'
)
.
where
(
'file_store
is
NULL'
)
.
where
(
id:
(
start_id
..
stop_id
))
.
where
(
id:
(
start_id
..
stop_id
))
.
update_all
(
file_store:
1
)
.
update_all
(
file_store:
1
)
end
end
...
...
lib/gitlab/background_migration/fill_file_store_upload.rb
View file @
a366fa09
...
@@ -11,8 +11,8 @@ module Gitlab
...
@@ -11,8 +11,8 @@ module Gitlab
end
end
def
perform
(
start_id
,
stop_id
)
def
perform
(
start_id
,
stop_id
)
FillFileStoreUpload
::
Upload
Gitlab
::
BackgroundMigration
::
FillFileStoreUpload
::
Upload
.
where
(
'store
=
NULL'
)
.
where
(
'store
is
NULL'
)
.
where
(
id:
(
start_id
..
stop_id
))
.
where
(
id:
(
start_id
..
stop_id
))
.
update_all
(
store:
1
)
.
update_all
(
store:
1
)
end
end
...
...
spec/migrations/fill_file_store_spec.rb
0 → 100644
View file @
a366fa09
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20180424151928_fill_file_store'
)
describe
FillFileStore
,
:migration
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:builds
)
{
table
(
:ci_builds
)
}
let
(
:job_artifacts
)
{
table
(
:ci_job_artifacts
)
}
let
(
:lfs_objects
)
{
table
(
:lfs_objects
)
}
let
(
:uploads
)
{
table
(
:uploads
)
}
before
do
namespaces
.
create!
(
id:
123
,
name:
'gitlab1'
,
path:
'gitlab1'
)
projects
.
create!
(
id:
123
,
name:
'gitlab1'
,
path:
'gitlab1'
,
namespace_id:
123
)
builds
.
create!
(
id:
1
)
##
# Create rows that have nullfied `file_store` column
job_artifacts
.
create!
(
project_id:
123
,
job_id:
1
,
file_type:
1
,
file_store:
nil
)
lfs_objects
.
create!
(
oid:
123
,
size:
10
,
file:
'file_name'
,
file_store:
nil
)
uploads
.
create!
(
size:
10
,
path:
'path'
,
uploader:
'uploader'
,
mount_point:
'file_name'
,
store:
nil
)
end
it
'correctly migrates nullified file_store/store column'
do
expect
(
job_artifacts
.
where
(
file_store:
nil
).
count
).
to
eq
(
1
)
expect
(
lfs_objects
.
where
(
file_store:
nil
).
count
).
to
eq
(
1
)
expect
(
uploads
.
where
(
store:
nil
).
count
).
to
eq
(
1
)
expect
(
job_artifacts
.
where
(
file_store:
1
).
count
).
to
eq
(
0
)
expect
(
lfs_objects
.
where
(
file_store:
1
).
count
).
to
eq
(
0
)
expect
(
uploads
.
where
(
store:
1
).
count
).
to
eq
(
0
)
migrate!
expect
(
job_artifacts
.
where
(
file_store:
nil
).
count
).
to
eq
(
0
)
expect
(
lfs_objects
.
where
(
file_store:
nil
).
count
).
to
eq
(
0
)
expect
(
uploads
.
where
(
store:
nil
).
count
).
to
eq
(
0
)
expect
(
job_artifacts
.
where
(
file_store:
1
).
count
).
to
eq
(
1
)
expect
(
lfs_objects
.
where
(
file_store:
1
).
count
).
to
eq
(
1
)
expect
(
uploads
.
where
(
store:
1
).
count
).
to
eq
(
1
)
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