Skip to content

Commit d5811ae

Browse files
committed
chg: [sql] remove unnecessary not null constraint
1 parent 7a6f850 commit d5811ae

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787
recursive = flag.Bool("r", false, "should it open the directory recursively")
8888
tarball = flag.Bool("t", false, "is it a tar archive")
8989
format = flag.String("f", "json", "certificate file format [json, crt, der]")
90-
pull = flag.Bool("p", true, "pull from redis?")
90+
pull = flag.Bool("p", false, "pull from redis?")
9191
cr redis.Conn
9292
)
9393

@@ -380,8 +380,8 @@ func insertLeafCertificate(fp string, c certMapElm) error {
380380
}
381381
}
382382
J:
383-
// 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`
384-
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`
383+
// 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`
384+
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`
385385
_, err = db.Exec(q, c.CertHash, c.Certificate.IsCA, false, c.Certificate.Issuer.String(), c.Certificate.Subject.String(), nil, false, fp)
386386
fmt.Println(fp)
387387
if err != nil {
@@ -624,7 +624,7 @@ func unique(s []certMapElm) []certMapElm {
624624
}
625625

626626
func insertCertificate(fp string, c certMapElm) (string, error) {
627-
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`
627+
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`
628628
_, 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))
629629
if err != nil {
630630
return c.CertHash, err

passivessl.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ALTER TABLE public.public_key OWNER TO postgres;
6868
-- object: public.certificate | type: TABLE --
6969
-- DROP TABLE IF EXISTS public.certificate CASCADE;
7070
CREATE TABLE public.certificate(
71-
mounted_path character varying(4096) NOT NULL,
71+
mounted_path character varying(4096),
7272
issuer text,
7373
cert_chain ltree,
7474
subject text,
@@ -94,7 +94,7 @@ CREATE TABLE public.certificate(
9494
"PermittedURIDomains" text[],
9595
"ExcludedURIDomains" text[],
9696
fs_type smallint DEFAULT 0,
97-
atrest_path character varying(4096) NOT NULL,
97+
atrest_path character varying(4096),
9898
CONSTRAINT certificate_pk PRIMARY KEY (hash)
9999

100100
);

populate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
# Set PGPASSWORD first
3-
# export PGPASSWORD=postgres
3+
export PGPASSWORD=postgres
44
psql -hlocalhost -p5432 -Upostgres -f passivesslCreate.sql
55
psql -hlocalhost -p5432 -Upostgres -d p2 -f passivessl.sql

0 commit comments

Comments
 (0)