migrations: swap in new documentation table

Tests will break for this CL, because the tables have changed but tests
are still reading from new_documentation. Tests will pass once
CL 310313 has been merged, which should be merged at the same time as
this CL.

Change-Id: I260ef5b5812a6d7c081a3f3b67e1d4778c557920
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/310376
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/migrations/000090_rename_new_documentation.down.sql b/migrations/000090_rename_new_documentation.down.sql
new file mode 100644
index 0000000..9cb5f44
--- /dev/null
+++ b/migrations/000090_rename_new_documentation.down.sql
@@ -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;
+
+ALTER INDEX documentation_pkey RENAME TO new_documentation_pkey;
+ALTER INDEX documentation_unit_id_goos_goarch_key
+    RENAME TO new_documentation_unit_id_goos_goarch_key;
+ALTER TABLE documentation RENAME CONSTRAINT
+    documentation_unit_id_fkey TO new_documentation_unit_id_fkey;
+
+ALTER INDEX old_documentation_pkey RENAME TO documentation_pkey;
+ALTER TABLE old_documentation RENAME CONSTRAINT
+    old_documentation_unit_id_fkey TO documentation_path_id_fkey;
+
+ALTER TABLE documentation RENAME TO new_documentation;
+ALTER TABLE old_documentation RENAME TO documentation;
+
+END;
diff --git a/migrations/000090_rename_new_documentation.up.sql b/migrations/000090_rename_new_documentation.up.sql
new file mode 100644
index 0000000..72ea79c
--- /dev/null
+++ b/migrations/000090_rename_new_documentation.up.sql
@@ -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;
+
+ALTER TABLE documentation RENAME TO old_documentation;
+ALTER TABLE new_documentation RENAME TO documentation;
+
+ALTER INDEX documentation_pkey RENAME TO old_documentation_pkey;
+ALTER TABLE old_documentation RENAME CONSTRAINT
+    documentation_path_id_fkey TO old_documentation_unit_id_fkey;
+
+ALTER INDEX new_documentation_pkey RENAME TO documentation_pkey;
+ALTER INDEX new_documentation_unit_id_goos_goarch_key
+    RENAME TO documentation_unit_id_goos_goarch_key;
+ALTER TABLE documentation RENAME CONSTRAINT
+    new_documentation_unit_id_fkey TO documentation_unit_id_fkey;
+
+END;