diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-09-28 21:26:16 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:25:27 +0300 |
commit | b27549df97151f773c6fbfac4c9dc3aa491a8b5d (patch) | |
tree | 2eeb19000452adf02914e583020d9e024327ac2d /db/migrate/20170927161718_create_gpg_key_subkeys.rb | |
parent | 4b6d045c0c3c8d8ab70dd80feb960f193e498d7a (diff) |
Add some basic specs and refactor model and validations
Diffstat (limited to 'db/migrate/20170927161718_create_gpg_key_subkeys.rb')
-rw-r--r-- | db/migrate/20170927161718_create_gpg_key_subkeys.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb index 9f69e299874..ffe06ce1231 100644 --- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb +++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb @@ -1,11 +1,23 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration DOWNTIME = false - def change + def up create_table :gpg_key_subkeys do |t| t.binary :keyid t.binary :fingerprint + t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade } + + t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil + t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil end + + 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 end end |