Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
337
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
23
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
6875b68f
Commit
6875b68f
authored
7 years ago
by
otofune
Browse files
Options
Downloads
Patches
Plain Diff
change all migrations to parallely
parent
9f2dc280
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/migration/change-gridfs-metadata-name-to-filename.js
+22
-2
22 additions, 2 deletions
tools/migration/change-gridfs-metadata-name-to-filename.js
tools/migration/issue_882.js
+23
-20
23 additions, 20 deletions
tools/migration/issue_882.js
with
45 additions
and
22 deletions
tools/migration/change-gridfs-metadata-name-to-filename.js
+
22
−
2
View file @
6875b68f
...
...
@@ -19,12 +19,32 @@ async function applyNewChange (doc) {
}
async
function
main
()
{
const
oldTypeDocs
=
await
DriveFile
.
find
(
{
const
query
=
{
'
metadata.name
'
:
{
$exists
:
true
}
}
const
count
=
await
DriveFile
.
count
(
query
)
const
dop
=
Number
.
parseInt
(
process
.
argv
[
2
])
||
5
const
idop
=
((
count
-
(
count
%
dop
))
/
dop
)
+
1
return
zip
(
1
,
async
(
time
)
=>
{
console
.
log
(
`
${
time
}
/
${
idop
}
`
)
const
doc
=
await
db
.
get
(
'
drive_files
'
).
find
(
query
,
{
limit
:
dop
,
skip
:
time
*
dop
})
return
Promise
.
all
(
doc
.
map
(
applyNewChange
))
},
idop
).
then
(
a
=>
{
const
rv
=
[]
a
.
forEach
(
e
=>
rv
.
push
(...
e
))
return
rv
})
return
await
Promise
.
all
(
oldTypeDocs
.
map
(
applyNewChange
))
}
main
().
then
(
console
.
dir
).
catch
(
console
.
error
)
This diff is collapsed.
Click to expand it.
tools/migration/issue_882.js
+
23
−
20
View file @
6875b68f
// for Node.js interpret
const
{
default
:
DriveFile
}
=
require
(
'
../../built/api/models/drive-file
'
)
const
{
default
:
zip
}
=
require
(
'
@prezzemolo/zip
'
)
const
migrate
=
async
(
doc
)
=>
{
const
result
=
await
DriveFile
.
update
(
doc
.
_id
,
{
...
...
@@ -15,30 +16,32 @@ const migrate = async (doc) => {
}
async
function
main
()
{
let
i
=
0
;
const
count
=
await
DriveFile
.
count
({});
const
iterate
=
async
()
=>
{
if
(
i
==
count
)
return
true
;
console
.
log
(
`
${
i
}
/
${
count
}
`
);
const
doc
=
(
await
DriveFile
.
find
({},
{
limit
:
1
,
skip
:
i
}))[
0
]
const
res
=
await
migrate
(
doc
);
if
(
!
res
)
{
return
false
;
}
else
{
i
++
return
await
iterate
();
const
query
=
{
'
metadata.type
'
:
{
$exists
:
true
}
}
const
res
=
await
iterate
(
);
const
count
=
await
DriveFile
.
count
(
query
);
if
(
res
)
{
return
'
ok
'
;
}
else
{
throw
'
something happened
'
;
}
const
dop
=
Number
.
parseInt
(
process
.
argv
[
2
])
||
5
const
idop
=
((
count
-
(
count
%
dop
))
/
dop
)
+
1
return
zip
(
1
,
async
(
time
)
=>
{
console
.
log
(
`
${
time
}
/
${
idop
}
`
)
const
doc
=
await
db
.
get
(
'
drive_files
'
).
find
(
query
,
{
limit
:
dop
,
skip
:
time
*
dop
})
return
Promise
.
all
(
doc
.
map
(
migrate
))
},
idop
).
then
(
a
=>
{
const
rv
=
[]
a
.
forEach
(
e
=>
rv
.
push
(...
e
))
return
rv
})
}
main
().
then
(
console
.
dir
).
catch
(
console
.
error
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment