aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthan Lee <ethanalee@google.com>2025-11-17 10:25:49 -0800
committerEthan Lee <ethanalee@google.com>2025-11-17 11:08:14 -0800
commit519903f45a28ca8a24ca36f9ac86eb2e24cc3af2 (patch)
tree796a4cf2b98a2640dffc09c39627223563344600
parenteaf237733d265b7045c7c51bd4b3989afeb56e4b (diff)
downloadgo-x-pkgsite-519903f45a28ca8a24ca36f9ac86eb2e24cc3af2.tar.xz
Revert "migrations: add num_imports column to units table"
This reverts commit c7fc077fc0e70e6198224f86ef70901c94919a4f. Reason for revert: migration times out Change-Id: I2d41309f19463226cfca0c97940d6ab464f73ce0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/721100 kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
-rw-r--r--migrations/000157_add_num_imports_col_to_units.down.sql9
-rw-r--r--migrations/000157_add_num_imports_col_to_units.up.sql25
2 files changed, 0 insertions, 34 deletions
diff --git a/migrations/000157_add_num_imports_col_to_units.down.sql b/migrations/000157_add_num_imports_col_to_units.down.sql
deleted file mode 100644
index 75b9a936..00000000
--- a/migrations/000157_add_num_imports_col_to_units.down.sql
+++ /dev/null
@@ -1,9 +0,0 @@
--- Copyright 2025 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 units DROP COLUMN num_imports;
-
-END;
diff --git a/migrations/000157_add_num_imports_col_to_units.up.sql b/migrations/000157_add_num_imports_col_to_units.up.sql
deleted file mode 100644
index 7da8d12f..00000000
--- a/migrations/000157_add_num_imports_col_to_units.up.sql
+++ /dev/null
@@ -1,25 +0,0 @@
--- Copyright 2025 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 units ADD COLUMN num_imports INTEGER;
-
--- Backfill the num_imports column with the count of imports for each unit.
--- This UPDATE uses a subquery to count imports per unit_id from the imports table.
-UPDATE units u
-SET num_imports = sub.import_count
-FROM (
- SELECT unit_id, COUNT(unit_id) AS import_count
- FROM imports
- GROUP BY unit_id
-) AS sub
-WHERE u.id = sub.unit_id;
-
--- Set num_imports to 0 for units that have no entries in the imports table.
-UPDATE units
-SET num_imports = 0
-WHERE num_imports IS NULL;
-
-END;