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 13:14:28 -04:00
|
|
|
create_table :rsa_keys do |t|
|
2019-09-11 04:17:24 -04:00
|
|
|
t.timestamps null: false
|
|
|
|
|
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-12 01:00:50 -04:00
|
|
|
t.integer :bits, null: false
|
|
|
|
t.string :sha1, null: false
|
|
|
|
t.string :sha256, null: false
|
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 13:14:28 -04:00
|
|
|
constraint :rsa_keys, :bits, <<~SQL
|
2019-09-11 04:17:24 -04:00
|
|
|
bits in (2048, 4096)
|
|
|
|
SQL
|
|
|
|
|
|
|
|
create_table :x509_certificates do |t|
|
|
|
|
t.timestamps null: false
|
|
|
|
|
2019-09-13 13:14:28 -04:00
|
|
|
t.references :rsa_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
|