Skip to content

Commit

Permalink
chg: [sql] remove unnecessary not null constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
gallypette committed Nov 18, 2020
1 parent 7a6f850 commit d5811ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions passivessl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

);
Expand Down
2 changes: 1 addition & 1 deletion populate.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d5811ae

Please sign in to comment.