migrations: use expression index on package_symbols

The UNIQUE INDEX on
package_symbols_package_path_id_module_path_id_section_synopsis_key is
changed such that the uuid of synopsis is used instead of the synopsis
string.

This is because the synopsis can be very long, whereas
uuid_generate_v5(uuid_nil(), synopsis) is fixed at 128 bits.

In CL 298769, this was attempted using a sha256. However, this fails on
strings when handling escape strings. CL 299329 was the revert.

Change-Id: I3102c32bcb5e54a64a44ef88c111a36300da83ea
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299351
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Julie Qiu 2021-03-04 12:12:47 -05:00
Родитель 26f430ccaf
Коммит a883572b0a
2 изменённых файлов: 25 добавлений и 0 удалений

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

@ -0,0 +1,12 @@
-- 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 INDEX package_symbols_package_path_id_module_path_id_section_synopsis_key;
CREATE UNIQUE INDEX package_symbols_package_path_id_module_path_id_section_synopsis_key
ON package_symbols(package_path_id, module_path_id, section, synopsis);
END;

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

@ -0,0 +1,13 @@
-- 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 INDEX package_symbols_package_path_id_module_path_id_section_synopsis_key;
CREATE UNIQUE INDEX package_symbols_package_path_id_module_path_id_section_synopsis_key
ON package_symbols(package_path_id, module_path_id, section,
uuid_generate_v5(uuid_nil(), synopsis));
END;