Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. -- Distribution
  2. --- a unique distribution discovered by a scanner
  3. CREATE TABLE dist (
  4. id SERIAL PRIMARY KEY,
  5. name text,
  6. version text,
  7. version_code_name text,
  8. version_id text,
  9. arch text,
  10. unique(name, version, version_code_name, version_id, arch)
  11. );
  12. CREATE INDEX dist_unique_idx ON dist (name, version, version_code_name, version_id, arch);
  13. CREATE INDEX dist_name_idx ON dist (name);
  14. CREATE INDEX dist_version_idx ON dist (version);
  15. CREATE INDEX dist_version_code_name_idx ON dist (version_code_name);
  16. CREATE INDEX dist_version_id_idx ON dist (version_id);
  17. CREATE INDEX dist_arch_idx ON dist (arch);
  18.  
  19. --- Package
  20. --- a unique package discovered by a scanner
  21. CREATE TABLE package (
  22. id SERIAL PRIMARY KEY,
  23. name text NOT NULL,
  24. kind text NOT NULL,
  25. version text NOT NULL,
  26. unique(name, version, kind)
  27. );
  28. CREATE INDEX package_unique_idx ON package (name, version, kind);
  29. CREATE INDEX package_name_idx ON package (name);
  30. CREATE INDEX package_version_idx ON package (version);
  31. CREATE INDEX package_kind_idx ON package (kind);
  32.  
  33. --- Scanner
  34. --- a unique versioned scanner which is responsible
  35. --- for finding packages and distributions in a layer
  36. CREATE TABLE scanner (
  37. id SERIAL PRIMARY KEY,
  38. name text NOT NULL,
  39. version text NOT NULL,
  40. kind text NOT NULL,
  41. unique(name, version, kind)
  42. );
  43. CREATE INDEX scanner_unique_idx ON scanner (name, kind, version);
  44. CREATE INDEX scanner_name_idx ON scanner (name);
  45. CREATE INDEX scanner_kind_idx ON scanner (kind);
  46. CREATE INDEX scanner_version_idx ON scanner (version);
  47.  
  48. --- ScannerList
  49. --- a relation informing us if a manifest hash has
  50. --- been scanned by a particular scanner
  51. CREATE TABLE scannerlist (
  52. id SERIAL PRIMARY KEY,
  53. manifest_hash text,
  54. scanner_id int REFERENCES scanner(id)
  55. );
  56. CREATE INDEX scannerlist_manifest_hash_idx ON scannerlist (manifest_hash);
  57.  
  58. --- ScanArtifact
  59. --- a relation representing the artifacts a scanner discovered
  60. --- loosely couples packages to their distribution context and
  61. --- lastly to the layer the pair was found in
  62. CREATE TABLE scanartifact (
  63. id SERIAL PRIMARY KEY,
  64. layer_hash text,
  65. kind text,
  66. package_id int REFERENCES package(id),
  67. dist_id int REFERENCES dist(id),
  68. source_id int REFERENCES package(id),
  69. scanner_id int REFERENCES scanner(id),
  70. unique(layer_hash, kind, package_id, dist_id, source_id, scanner_id)
  71. );
  72. CREATE INDEX scanartifact_unique_idx ON scanartifact (layer_hash, kind, package_id, dist_id, source_id, scanner_id);
  73. CREATE INDEX scanartifact_layer_hash_idx ON scanartifact (layer_hash);
  74. CREATE INDEX scanartifact_layer_hash_scanner_id_idx ON scanartifact (layer_hash, scanner_id);
  75.  
  76. --- ScanReport
  77. CREATE TABLE scanreport (
  78. manifest_hash text PRIMARY KEY,
  79. state text,
  80. scan_result jsonb
  81. );
  82. CREATE INDEX scanreport_manifest_hash_idx ON scanreport (manifest_hash);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement