From bda006f3191a51247332f00ecdead68038e5ba49 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Mon, 26 Oct 2020 10:33:25 -0400 Subject: [PATCH] migrations: change licenses PK to (module_id, file_path) The primary key for licenses is changed to (module_id, file_path). The licenses.module_path and licenses.version columns will be dropped in a future CL. For golang/go#39629 Change-Id: I3ae8f7c582013a897152bdf5926f6a9287136c5e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265019 Trust: Julie Qiu Run-TryBot: Julie Qiu Reviewed-by: Jamal Carvalho TryBot-Result: kokoro --- .../000036_change_licenses_primary_key.down.sql | 11 +++++++++++ migrations/000036_change_licenses_primary_key.up.sql | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 migrations/000036_change_licenses_primary_key.down.sql create mode 100644 migrations/000036_change_licenses_primary_key.up.sql diff --git a/migrations/000036_change_licenses_primary_key.down.sql b/migrations/000036_change_licenses_primary_key.down.sql new file mode 100644 index 00000000..4d4a4a44 --- /dev/null +++ b/migrations/000036_change_licenses_primary_key.down.sql @@ -0,0 +1,11 @@ +-- Copyright 2020 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 INDEX idx_licenses_module_id ON licenses (module_id); +ALTER TABLE licenses DROP CONSTRAINT licenses_pkey; +ALTER TABLE licenses ADD PRIMARY KEY (module_path, version, file_path); + +END; diff --git a/migrations/000036_change_licenses_primary_key.up.sql b/migrations/000036_change_licenses_primary_key.up.sql new file mode 100644 index 00000000..69ea921c --- /dev/null +++ b/migrations/000036_change_licenses_primary_key.up.sql @@ -0,0 +1,11 @@ +-- Copyright 2020 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; + +ALTER TABLE licenses DROP CONSTRAINT licenses_pkey; +ALTER TABLE licenses ADD PRIMARY KEY (module_id, file_path); +DROP INDEX idx_licenses_module_id; + +END;