2017-09-27 13:27:39 -04:00
|
|
|
class CreateGpgKeySubkeys < ActiveRecord::Migration
|
2017-09-27 21:47:15 -04:00
|
|
|
DOWNTIME = false
|
|
|
|
|
2017-09-28 14:26:16 -04:00
|
|
|
def up
|
2017-09-27 13:27:39 -04:00
|
|
|
create_table :gpg_key_subkeys do |t|
|
2017-10-04 11:34:50 -04:00
|
|
|
t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade }
|
|
|
|
|
2017-09-27 13:27:39 -04:00
|
|
|
t.binary :keyid
|
|
|
|
t.binary :fingerprint
|
2017-09-28 14:26:16 -04:00
|
|
|
|
|
|
|
t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
|
|
|
|
t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
|
2017-09-27 13:27:39 -04:00
|
|
|
end
|
2017-09-28 14:26:16 -04:00
|
|
|
|
|
|
|
add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_reference(:gpg_signatures, :gpg_key_subkey, index: true, foreign_key: true)
|
|
|
|
|
|
|
|
drop_table :gpg_key_subkeys
|
2017-09-27 13:27:39 -04:00
|
|
|
end
|
|
|
|
end
|