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
70a71704
Commit
70a71704
authored
Jan 24, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-requeue-pending-delete' into 'master'
Requeue projects pending deletion See merge request !8438
parents
58786a7a
e4d40242
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
changelogs/unreleased/zj-requeue-pending-delete.yml
changelogs/unreleased/zj-requeue-pending-delete.yml
+4
-0
db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
...migrate/20170104150317_requeue_pending_delete_projects.rb
+49
-0
No files found.
changelogs/unreleased/zj-requeue-pending-delete.yml
0 → 100644
View file @
70a71704
---
title
:
Requeue pending deletion projects
merge_request
:
author
:
db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
0 → 100644
View file @
70a71704
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RequeuePendingDeleteProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
admin
=
User
.
find_by
(
admin:
true
)
return
unless
admin
@offset
=
0
loop
do
ids
=
pending_delete_batch
break
if
ids
.
rows
.
count
.
zero?
args
=
ids
.
map
{
|
id
|
[
id
[
'id'
],
admin
.
id
,
{}]
}
Sidekiq
::
Client
.
push_bulk
(
'class'
=>
"ProjectDestroyWorker"
,
'args'
=>
args
)
@offset
+=
1
end
end
def
down
# noop
end
private
def
pending_delete_batch
connection
.
exec_query
(
find_batch
)
end
BATCH_SIZE
=
5000
def
find_batch
projects
=
Arel
::
Table
.
new
(
:projects
)
projects
.
project
(
projects
[
:id
]).
where
(
projects
[
:pending_delete
].
eq
(
true
)).
where
(
projects
[
:namespace_id
].
not_eq
(
nil
)).
skip
(
@offset
*
BATCH_SIZE
).
take
(
BATCH_SIZE
).
to_sql
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