migrations: create package_imports2 table

This will replace package_imports.

It has a BIGINT for the reference to unit_id, and switches to_path
from a string to a path id.

Change-Id: Ib2e50df2a7629fc202d993ae792890caee9c6d0e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/326130
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
This commit is contained in:
Jonathan Amsterdam 2021-06-08 13:57:16 -04:00
Родитель 9253744398
Коммит f4ff88d904
2 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,9 @@
-- Copyright 2021 The Go Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style
-- license that can be found in the LICENSE file.
BEGIN;
DROP TABLE imports;
END;

Просмотреть файл

@ -0,0 +1,20 @@
-- Copyright 2021 The Go Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style
-- license that can be found in the LICENSE file.
BEGIN;
CREATE TABLE imports (
unit_id BIGINT NOT NULL REFERENCES units(id) ON DELETE CASCADE,
to_path_id BIGINT NOT NULL REFERENCES paths(id) ON DELETE CASCADE,
PRIMARY KEY (unit_id, to_path_id)
);
COMMENT ON TABLE imports IS
'TABLE imports contains the imports for a package in the units table.
The package represented by unit_id imports to_path_id.
We do not store the version and module at which to_path is imported because it is hard to compute.';
CREATE INDEX idx_imports_to_path_id ON imports USING btree (to_path_id);
END;