1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/db/migrate/20190911081459_create_x509_...

54 lines
1.4 KiB
Ruby

# frozen_string_literal: true
class CreateX509Tables < ActiveRecord::Migration[6.0]
include Partynest::Migration
def change
create_table :asymmetric_keys do |t|
t.timestamps null: false
t.string :type, null: false
t.index %i[type id], unique: true
t.references :account, foreign_key: true
t.text :public_key_pem, null: false
t.binary :public_key_der, null: false
t.binary :private_key_pem_iv
t.binary :private_key_pem_ciphertext
t.boolean :has_password, null: false
t.string :sha1, null: false
t.string :sha256, null: false
t.integer :bits
t.string :curve
t.index :public_key_pem, unique: true
t.index :public_key_der, unique: true
t.index :sha1, unique: true
t.index :sha256, unique: true
end
constraint :asymmetric_keys, :bits, <<~SQL
bits IS NULL OR bits IN (2048, 4096)
SQL
constraint :asymmetric_keys, :curve, <<~SQL
curve IS NULL OR curve IN ('prime256v1', 'secp384r1')
SQL
create_table :x509_certificates do |t|
t.timestamps null: false
t.references :asymmetric_key, null: false, foreign_key: true
t.text :pem, null: false
t.string :subject, null: false
t.string :issuer, null: false
t.datetime :not_before, null: false
t.datetime :not_after, null: false
end
end
end