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

54 lines
1.4 KiB
Ruby
Raw Normal View History

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
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
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
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
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
2019-09-11 04:17:24 -04:00
end
end
end