1
0
Fork 0

Add column AsymmetricKey#curve

This commit is contained in:
Alex Kotov 2019-09-14 04:02:00 +05:00
parent d779cea747
commit d47a8bba61
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 8 additions and 1 deletions

View file

@ -22,6 +22,7 @@ class CreateX509Tables < ActiveRecord::Migration[6.0]
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
@ -33,6 +34,10 @@ class CreateX509Tables < ActiveRecord::Migration[6.0]
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

View file

@ -382,7 +382,9 @@ CREATE TABLE public.asymmetric_keys (
sha1 character varying NOT NULL,
sha256 character varying NOT NULL,
bits integer,
CONSTRAINT bits CHECK (((bits IS NULL) OR (bits = ANY (ARRAY[2048, 4096]))))
curve character varying,
CONSTRAINT bits CHECK (((bits IS NULL) OR (bits = ANY (ARRAY[2048, 4096])))),
CONSTRAINT curve CHECK (((curve IS NULL) OR ((curve)::text = ANY ((ARRAY['prime256v1'::character varying, 'secp384r1'::character varying])::text[]))))
);