database: add created_at field for layers and vulnerabilities

This commit is contained in:
Quentin Machu 2016-02-04 11:37:04 -05:00 committed by Jimmy Zelinskie
parent f351d6304e
commit ccaaff000e
2 changed files with 7 additions and 5 deletions

View File

@ -30,7 +30,8 @@ CREATE TABLE IF NOT EXISTS Layer (
name VARCHAR(128) NOT NULL UNIQUE, name VARCHAR(128) NOT NULL UNIQUE,
engineversion SMALLINT NOT NULL, engineversion SMALLINT NOT NULL,
parent_id INT NULL REFERENCES Layer ON DELETE CASCADE, 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 (parent_id);
CREATE INDEX ON Layer (namespace_id); CREATE INDEX ON Layer (namespace_id);

View File

@ -115,8 +115,9 @@ func init() {
AND v.deleted_at IS NULL` AND v.deleted_at IS NULL`
queries["i_layer"] = ` queries["i_layer"] = `
INSERT INTO Layer(name, engineversion, parent_id, namespace_id) INSERT INTO Layer(name, engineversion, parent_id, namespace_id, created_at)
VALUES($1, $2, $3, $4) RETURNING id` VALUES($1, $2, $3, $4, CURRENT_TIMESTAMP)
RETURNING id`
queries["u_layer"] = `UPDATE LAYER SET engineversion = $2, namespace_id = $3 WHERE id = $1` queries["u_layer"] = `UPDATE LAYER SET engineversion = $2, namespace_id = $3 WHERE id = $1`
@ -158,8 +159,8 @@ func init() {
WHERE vfif.vulnerability_id = $1` WHERE vfif.vulnerability_id = $1`
queries["i_vulnerability"] = ` queries["i_vulnerability"] = `
INSERT INTO Vulnerability(namespace_id, name, description, link, severity, metadata) INSERT INTO Vulnerability(namespace_id, name, description, link, severity, metadata, created_at)
VALUES($1, $2, $3, $4, $5, $6) VALUES($1, $2, $3, $4, $5, $6, CURRENT_TIMESTAMP)
RETURNING id` RETURNING id`
queries["i_vulnerability_fixedin_feature"] = ` queries["i_vulnerability_fixedin_feature"] = `