From 740e9bddf1c62ac4d4aeea1c4855322cffd0e7d2 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Fri, 30 Apr 2021 12:57:17 -0400 Subject: [PATCH] migrations: change symbol_history.id to BIGINT The symbol_history.id column is changed from an INT to a BIGINT. Rather than change the column type, we drop the entire table since we need to reprocess everything anyways. For golang/go#37102 Change-Id: I8aedaf73bfd41b71005d630c011c92da1686f580 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/315709 Trust: Julie Qiu Run-TryBot: Julie Qiu TryBot-Result: kokoro Reviewed-by: Jonathan Amsterdam --- .../000094_alter_symbol_history.down.sql | 30 +++++++++++++++++++ migrations/000094_alter_symbol_history.up.sql | 30 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 migrations/000094_alter_symbol_history.down.sql create mode 100644 migrations/000094_alter_symbol_history.up.sql diff --git a/migrations/000094_alter_symbol_history.down.sql b/migrations/000094_alter_symbol_history.down.sql new file mode 100644 index 00000000..69b7f997 --- /dev/null +++ b/migrations/000094_alter_symbol_history.down.sql @@ -0,0 +1,30 @@ +-- 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 symbol_history; +CREATE TABLE symbol_history ( + id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + package_path_id INTEGER NOT NULL, + module_path_id INTEGER NOT NULL, + symbol_name_id INTEGER NOT NULL, + parent_symbol_name_id INTEGER NOT NULL, + package_symbol_id INTEGER NOT NULL, + since_version TEXT NOT NULL CHECK(since_version != ''), + sort_version text NOT NULL, + goos goos NOT NULL, + goarch goarch NOT NULL, + + UNIQUE( package_path_id, module_path_id, symbol_name_id, goos, goarch), + FOREIGN KEY (package_path_id) REFERENCES paths(id) ON DELETE CASCADE, + FOREIGN KEY (module_path_id) REFERENCES paths(id) ON DELETE CASCADE, + FOREIGN KEY (symbol_name_id) REFERENCES symbol_names(id) ON DELETE CASCADE, + FOREIGN KEY (parent_symbol_name_id) REFERENCES symbol_names(id) ON DELETE CASCADE, + FOREIGN KEY (package_symbol_id) REFERENCES package_symbols(id) ON DELETE CASCADE +); + +END; diff --git a/migrations/000094_alter_symbol_history.up.sql b/migrations/000094_alter_symbol_history.up.sql new file mode 100644 index 00000000..aa0d05ef --- /dev/null +++ b/migrations/000094_alter_symbol_history.up.sql @@ -0,0 +1,30 @@ +-- 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 symbol_history; +CREATE TABLE symbol_history ( + id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + package_path_id INTEGER NOT NULL, + module_path_id INTEGER NOT NULL, + symbol_name_id INTEGER NOT NULL, + parent_symbol_name_id INTEGER NOT NULL, + package_symbol_id INTEGER NOT NULL, + since_version TEXT NOT NULL CHECK(since_version != ''), + sort_version text NOT NULL, + goos goos NOT NULL, + goarch goarch NOT NULL, + + UNIQUE( package_path_id, module_path_id, symbol_name_id, goos, goarch), + FOREIGN KEY (package_path_id) REFERENCES paths(id) ON DELETE CASCADE, + FOREIGN KEY (module_path_id) REFERENCES paths(id) ON DELETE CASCADE, + FOREIGN KEY (symbol_name_id) REFERENCES symbol_names(id) ON DELETE CASCADE, + FOREIGN KEY (parent_symbol_name_id) REFERENCES symbol_names(id) ON DELETE CASCADE, + FOREIGN KEY (package_symbol_id) REFERENCES package_symbols(id) ON DELETE CASCADE +); + +END;