20170927161718_create_gpg_key_subkeys.rb 730 Bytes
Newer Older
1
class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2]
2 3
  include Gitlab::Database::MigrationHelpers

4 5
  DOWNTIME = false

6
  def up
7
    create_table :gpg_key_subkeys do |t|
8 9
      t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade }

10 11
      t.binary :keyid
      t.binary :fingerprint
12

13 14
      t.index :keyid, unique: true, length: mysql_compatible_index_length
      t.index :fingerprint, unique: true, length: mysql_compatible_index_length
15
    end
16 17 18 19 20 21 22 23

    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
24 25
  end
end