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
ecfe6292
Commit
ecfe6292
authored
Oct 02, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to generate GpgKeySubkeys records and update signatures
parent
85c6652a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb
...002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb
+59
-0
No files found.
db/migrate/20171002161539_create_gpg_key_subkeys_for_existing_gpg_keys.rb
0 → 100644
View file @
ecfe6292
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
CreateGpgKeySubkeysForExistingGpgKeys
<
ActiveRecord
::
Migration
disable_ddl_transaction!
DOWNTIME
=
false
class
GpgKey
<
ActiveRecord
::
Base
self
.
table_name
=
'gpg_keys'
include
EachBatch
include
ShaAttribute
sha_attribute
:primary_keyid
sha_attribute
:fingerprint
has_many
:subkeys
,
class_name:
'GpgKeySubkey'
end
class
GpgKeySubkey
<
ActiveRecord
::
Base
self
.
table_name
=
'gpg_key_subkeys'
include
ShaAttribute
sha_attribute
:keyid
sha_attribute
:fingerprint
end
def
up
GpgKey
.
each_batch
do
|
batch
|
batch
.
each
do
|
gpg_key
|
create_subkeys
(
gpg_key
)
&&
update_signatures
(
gpg_key
)
end
end
end
def
down
end
private
def
create_subkeys
(
gpg_key
)
gpg_subkeys
=
Gitlab
::
Gpg
.
subkeys_from_key
(
gpg_key
.
key
)
gpg_subkeys
[
gpg_key
.
primary_keyid
.
upcase
]
&
.
each
do
|
subkey_data
|
gpg_key
.
subkeys
.
build
(
keyid:
subkey_data
[
:keyid
],
fingerprint:
subkey_data
[
:fingerprint
])
end
# Improve latency by doing all INSERTs in a single call
GpgKey
.
transaction
do
gpg_key
.
save!
end
end
def
update_signatures
(
gpg_key
)
InvalidGpgSignatureUpdateWorker
.
perform_async
(
gpg_key
.
id
)
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