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
Boxiang Sun
gitlab-ce
Commits
a6b60fee
Commit
a6b60fee
authored
Jul 17, 2019
by
Etienne Baqué
Committed by
Stan Hu
Aug 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Iterating through token to encrypt with find_each
parent
3e48d419
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
...st_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
+2
-2
No files found.
db/post_migrate/20190711201818_encrypt_deploy_tokens_tokens.rb
View file @
a6b60fee
...
...
@@ -9,7 +9,7 @@ class EncryptDeployTokensTokens < ActiveRecord::Migration[5.1]
def
up
say_with_time
(
"Encrypting tokens from deploy_tokens"
)
do
DeploymentTokens
.
where
(
'token_encrypted is NULL AND token IS NOT NULL'
).
find_each
do
|
deploy_token
|
DeploymentTokens
.
where
(
'token_encrypted is NULL AND token IS NOT NULL'
).
find_each
(
batch_size:
10000
)
do
|
deploy_token
|
token_encrypted
=
Gitlab
::
CryptoHelper
.
aes256_gcm_encrypt
(
deploy_token
.
token
)
deploy_token
.
update!
(
token_encrypted:
token_encrypted
)
end
...
...
@@ -18,7 +18,7 @@ class EncryptDeployTokensTokens < ActiveRecord::Migration[5.1]
def
down
say_with_time
(
"Decrypting tokens from deploy_tokens"
)
do
DeploymentTokens
.
where
(
'token_encrypted IS NOT NULL AND token IS NULL'
).
find_each
do
|
deploy_token
|
DeploymentTokens
.
where
(
'token_encrypted IS NOT NULL AND token IS NULL'
).
find_each
(
batch_size:
10000
)
do
|
deploy_token
|
token
=
Gitlab
::
CryptoHelper
.
aes256_gcm_decrypt
(
deploy_token
.
token_encrypted
)
deploy_token
.
update!
(
token:
token
)
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