|
| 1 | +-- Copyright 2020 The Go Authors. All rights reserved. |
| 2 | +-- Use of this source code is governed by a BSD-style |
| 3 | +-- license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +BEGIN; |
| 6 | + |
| 7 | +CREATE TABLE packages ( |
| 8 | + path text NOT NULL, |
| 9 | + module_path text NOT NULL, |
| 10 | + version text NOT NULL, |
| 11 | + commit_time timestamp with time zone NOT NULL, |
| 12 | + name text NOT NULL, |
| 13 | + synopsis text, |
| 14 | + license_types text[], |
| 15 | + license_paths text[], |
| 16 | + v1_path text NOT NULL, |
| 17 | + goos text NOT NULL, |
| 18 | + goarch text NOT NULL, |
| 19 | + redistributable boolean DEFAULT false NOT NULL, |
| 20 | + documentation text, |
| 21 | + tsv_parent_directories tsvector, |
| 22 | + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 23 | + updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 24 | + PRIMARY KEY (path, module_path, version), |
| 25 | + FOREIGN KEY (module_path, version) REFERENCES modules(module_path, version) ON DELETE CASCADE |
| 26 | +); |
| 27 | +COMMENT ON TABLE packages IS |
| 28 | +'TABLE packages contains packages in a specific module version.'; |
| 29 | +COMMENT ON COLUMN packages.commit_time IS |
| 30 | +'commit_time is the same as verions.commit_time. It is added here so that we can reduce the number of joins in our queries.'; |
| 31 | +COMMENT ON COLUMN packages.tsv_parent_directories IS |
| 32 | +'tsv_parent_directories should always be NOT NULL, but it is populated by a trigger, so it will be initially NULL on insert.'; |
| 33 | + |
| 34 | +CREATE INDEX idx_packages_v1_path ON packages (v1_path); |
| 35 | +COMMENT ON INDEX idx_packages_v1_path IS |
| 36 | +'INDEX idx_packages_v1_path is used to get all of the packages in a series.'; |
| 37 | + |
| 38 | +CREATE INDEX idx_packages_module_path_text_pattern_ops ON packages (module_path text_pattern_ops); |
| 39 | +COMMENT ON INDEX idx_packages_module_path_text_pattern_ops IS |
| 40 | +'INDEX idx_packages_module_path_text_pattern_ops is used to improve performance of LIKE statements for module_path. It is used to fetch directories matching a given module_path prefix.'; |
| 41 | + |
| 42 | +CREATE INDEX idx_packages_path_text_pattern_ops ON packages (path text_pattern_ops); |
| 43 | + |
| 44 | +END; |
0 commit comments