chg: [sql] remove unnecessary not null constraint

master v0.2.1
Jean-Louis Huynen 2020-11-18 16:16:46 +01:00
parent 7a6f8505a7
commit d5811ae08e
No known key found for this signature in database
GPG Key ID: 64799157F4BD6B93
3 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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)
);

View File

@ -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