2019-09-11 04:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CreateX509Tables < ActiveRecord::Migration[6.0]
|
|
|
|
include Partynest::Migration
|
|
|
|
|
|
|
|
def change
|
2019-09-13 14:03:33 -04:00
|
|
|
create_table :asymmetric_keys do |t|
|
2019-09-11 04:17:24 -04:00
|
|
|
t.timestamps null: false
|
2019-09-13 14:03:33 -04:00
|
|
|
t.string :type, null: false
|
|
|
|
t.index %i[type id], unique: true
|
2019-09-11 04:17:24 -04:00
|
|
|
|
2019-09-13 15:26:43 -04:00
|
|
|
t.references :account, foreign_key: true
|
|
|
|
|
2019-09-13 08:52:03 -04:00
|
|
|
t.text :public_key_pem, null: false
|
|
|
|
t.binary :public_key_der, null: false
|
2019-09-11 04:17:24 -04:00
|
|
|
|
2019-09-11 17:12:14 -04:00
|
|
|
t.binary :private_key_pem_iv
|
|
|
|
t.binary :private_key_pem_ciphertext
|
|
|
|
|
2019-09-13 16:48:33 -04:00
|
|
|
t.boolean :has_password, null: false
|
|
|
|
t.string :sha1, null: false
|
|
|
|
t.string :sha256, null: false
|
2019-09-11 21:48:26 -04:00
|
|
|
|
2019-09-13 18:26:03 -04:00
|
|
|
t.integer :bits
|
2019-09-13 19:02:00 -04:00
|
|
|
t.string :curve
|
2019-09-13 18:26:03 -04:00
|
|
|
|
2019-09-11 21:48:26 -04:00
|
|
|
t.index :public_key_pem, unique: true
|
2019-09-13 08:52:03 -04:00
|
|
|
t.index :public_key_der, unique: true
|
2019-09-12 01:00:50 -04:00
|
|
|
t.index :sha1, unique: true
|
|
|
|
t.index :sha256, unique: true
|
2019-09-11 04:17:24 -04:00
|
|
|
end
|
|
|
|
|
2019-09-13 14:03:33 -04:00
|
|
|
constraint :asymmetric_keys, :bits, <<~SQL
|
2019-09-13 19:02:40 -04:00
|
|
|
bits IS NULL OR bits IN (2048, 4096)
|
2019-09-11 04:17:24 -04:00
|
|
|
SQL
|
|
|
|
|
2019-09-13 19:02:00 -04:00
|
|
|
constraint :asymmetric_keys, :curve, <<~SQL
|
2019-09-13 19:02:40 -04:00
|
|
|
curve IS NULL OR curve IN ('prime256v1', 'secp384r1')
|
2019-09-13 19:02:00 -04:00
|
|
|
SQL
|
|
|
|
|
2019-09-11 04:17:24 -04:00
|
|
|
create_table :x509_certificates do |t|
|
|
|
|
t.timestamps null: false
|
|
|
|
|
2019-09-13 14:03:33 -04:00
|
|
|
t.references :asymmetric_key, null: false, foreign_key: true
|
2019-09-11 04:17:24 -04:00
|
|
|
|
2019-09-11 05:09:37 -04:00
|
|
|
t.text :pem, null: false
|
2019-09-11 08:03:14 -04:00
|
|
|
t.string :subject, null: false
|
|
|
|
t.string :issuer, null: false
|
2019-09-11 05:09:37 -04:00
|
|
|
t.datetime :not_before, null: false
|
|
|
|
t.datetime :not_after, null: false
|
2019-09-11 04:17:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|