Skip to content

Commit

Permalink
database: add created_at field for layers and vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-M authored and jzelinskie committed Feb 24, 2016
1 parent f351d63 commit ccaaff0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion database/pgsql/migrations/20151222113213_Initial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ CREATE TABLE IF NOT EXISTS Layer (
name VARCHAR(128) NOT NULL UNIQUE,
engineversion SMALLINT NOT NULL,
parent_id INT NULL REFERENCES Layer ON DELETE CASCADE,
namespace_id INT NULL REFERENCES Namespace);
namespace_id INT NULL REFERENCES Namespace,
created_at TIMESTAMP WITH TIME ZONE);

CREATE INDEX ON Layer (parent_id);
CREATE INDEX ON Layer (namespace_id);
Expand Down
9 changes: 5 additions & 4 deletions database/pgsql/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ func init() {
AND v.deleted_at IS NULL`

queries["i_layer"] = `
INSERT INTO Layer(name, engineversion, parent_id, namespace_id)
VALUES($1, $2, $3, $4) RETURNING id`
INSERT INTO Layer(name, engineversion, parent_id, namespace_id, created_at)
VALUES($1, $2, $3, $4, CURRENT_TIMESTAMP)
RETURNING id`

queries["u_layer"] = `UPDATE LAYER SET engineversion = $2, namespace_id = $3 WHERE id = $1`

Expand Down Expand Up @@ -158,8 +159,8 @@ func init() {
WHERE vfif.vulnerability_id = $1`

queries["i_vulnerability"] = `
INSERT INTO Vulnerability(namespace_id, name, description, link, severity, metadata)
VALUES($1, $2, $3, $4, $5, $6)
INSERT INTO Vulnerability(namespace_id, name, description, link, severity, metadata, created_at)
VALUES($1, $2, $3, $4, $5, $6, CURRENT_TIMESTAMP)
RETURNING id`

queries["i_vulnerability_fixedin_feature"] = `
Expand Down

0 comments on commit ccaaff0

Please sign in to comment.