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
89bb700c
Commit
89bb700c
authored
Aug 14, 2019
by
Adam Hegyi
Committed by
Mayra Cabrera
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate remaining users with null private_profile
parent
b3ca39aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
changelogs/unreleased/post-migrate-private-profile.yml
changelogs/unreleased/post-migrate-private-profile.yml
+5
-0
db/post_migrate/20190812070645_migrate_private_profile_nulls.rb
...t_migrate/20190812070645_migrate_private_profile_nulls.rb
+31
-0
db/schema.rb
db/schema.rb
+1
-1
No files found.
changelogs/unreleased/post-migrate-private-profile.yml
0 → 100644
View file @
89bb700c
---
title
:
Migrate remaining users with
null
private_profile
merge_request
:
31708
author
:
type
:
other
db/post_migrate/20190812070645_migrate_private_profile_nulls.rb
0 → 100644
View file @
89bb700c
# frozen_string_literal: true
class
MigratePrivateProfileNulls
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
DELAY
=
5
.
minutes
.
to_i
BATCH_SIZE
=
1_000
disable_ddl_transaction!
class
User
<
ActiveRecord
::
Base
self
.
table_name
=
'users'
include
::
EachBatch
end
def
up
# Migration will take about 7 hours
User
.
where
(
private_profile:
nil
).
each_batch
(
of:
BATCH_SIZE
)
do
|
batch
,
index
|
range
=
batch
.
pluck
(
Arel
.
sql
(
"MIN(id)"
),
Arel
.
sql
(
"MAX(id)"
)).
first
delay
=
index
*
DELAY
BackgroundMigrationWorker
.
perform_in
(
delay
.
seconds
,
'MigrateNullPrivateProfileToFalse'
,
[
*
range
])
end
end
def
down
# noop
end
end
db/schema.rb
View file @
89bb700c
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2019_08_
06_071559
)
do
ActiveRecord
::
Schema
.
define
(
version:
2019_08_
12_070645
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
...
...
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