From 519903f45a28ca8a24ca36f9ac86eb2e24cc3af2 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Mon, 17 Nov 2025 10:25:49 -0800 Subject: 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Findley --- .../000157_add_num_imports_col_to_units.down.sql | 9 -------- .../000157_add_num_imports_col_to_units.up.sql | 25 ---------------------- 2 files changed, 34 deletions(-) delete mode 100644 migrations/000157_add_num_imports_col_to_units.down.sql delete mode 100644 migrations/000157_add_num_imports_col_to_units.up.sql 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; -- cgit v1.3