forked from quay/claircore
/
migration4.go
38 lines (34 loc) · 865 Bytes
/
migration4.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package migrations
const (
// this migration modifies the database to support
// enrichments.
// see: https://github.com/quay/clair-enrichment-spec
migration4 = `
ALTER TABLE update_operation
ADD COLUMN kind text;
CREATE INDEX on update_operation (kind);
UPDATE update_operation
SET kind = 'vulnerability';
CREATE TABLE enrichment
(
id BIGSERIAL PRIMARY KEY,
hash_kind text,
hash bytea,
updater text,
tags text[],
data jsonb
);
CREATE UNIQUE INDEX ON enrichment (hash_kind, hash);
-- use inverted index for tags index
CREATE INDEX ON enrichment USING gin (tags);
CREATE TABLE uo_enrich
(
uo BIGINT REFERENCES update_operation (id),
enrich BIGINT REFERENCES enrichment (id),
updater text,
fingerprint text,
date timestamptz,
PRIMARY KEY (uo, enrich)
);
`
)