From d5811ae08e6fc65d628358b78a88bf2f547dcfcf Mon Sep 17 00:00:00 2001 From: Jean-Louis Huynen Date: Wed, 18 Nov 2020 16:16:46 +0100 Subject: [PATCH] chg: [sql] remove unnecessary not null constraint --- main.go | 8 ++++---- passivessl.sql | 4 ++-- populate.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 4e510c6..cc00ee4 100644 --- a/main.go +++ b/main.go @@ -87,7 +87,7 @@ var ( recursive = flag.Bool("r", false, "should it open the directory recursively") tarball = flag.Bool("t", false, "is it a tar archive") format = flag.String("f", "json", "certificate file format [json, crt, der]") - pull = flag.Bool("p", true, "pull from redis?") + pull = flag.Bool("p", false, "pull from redis?") cr redis.Conn ) @@ -380,8 +380,8 @@ func insertLeafCertificate(fp string, c certMapElm) error { } } J: - // q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, file_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING` - q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, file_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (hash) DO UPDATE SET file_path = excluded.file_path` + // q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, atrest_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING` + q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, atrest_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (hash) DO UPDATE SET atrest_path = excluded.atrest_path` _, err = db.Exec(q, c.CertHash, c.Certificate.IsCA, false, c.Certificate.Issuer.String(), c.Certificate.Subject.String(), nil, false, fp) fmt.Println(fp) if err != nil { @@ -624,7 +624,7 @@ func unique(s []certMapElm) []certMapElm { } func insertCertificate(fp string, c certMapElm) (string, error) { - q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, file_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING` + q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, atrest_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING` _, err := db.Exec(q, c.CertHash, c.Certificate.IsCA, c.chain.isSS, c.Certificate.Issuer.String(), c.Certificate.Subject.String(), c.chain.s, c.chain.isValid, getFullPath(fp, c.CertHash)) if err != nil { return c.CertHash, err diff --git a/passivessl.sql b/passivessl.sql index df3ef81..26ba285 100644 --- a/passivessl.sql +++ b/passivessl.sql @@ -68,7 +68,7 @@ ALTER TABLE public.public_key OWNER TO postgres; -- object: public.certificate | type: TABLE -- -- DROP TABLE IF EXISTS public.certificate CASCADE; CREATE TABLE public.certificate( - mounted_path character varying(4096) NOT NULL, + mounted_path character varying(4096), issuer text, cert_chain ltree, subject text, @@ -94,7 +94,7 @@ CREATE TABLE public.certificate( "PermittedURIDomains" text[], "ExcludedURIDomains" text[], fs_type smallint DEFAULT 0, - atrest_path character varying(4096) NOT NULL, + atrest_path character varying(4096), CONSTRAINT certificate_pk PRIMARY KEY (hash) ); diff --git a/populate.sh b/populate.sh index 3107f01..a3bc6de 100755 --- a/populate.sh +++ b/populate.sh @@ -1,5 +1,5 @@ #!/bin/bash # Set PGPASSWORD first -# export PGPASSWORD=postgres + export PGPASSWORD=postgres psql -hlocalhost -p5432 -Upostgres -f passivesslCreate.sql psql -hlocalhost -p5432 -Upostgres -d p2 -f passivessl.sql