From a796bab4a97e41d4aa143a21fe62d6ed7bcf1137 Mon Sep 17 00:00:00 2001 From: Urugonda Vishnu Date: Tue, 26 May 2026 09:09:18 +0530 Subject: [PATCH] Auto-run rowCount backfill during make dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #89 added a denormalized `rowCount` field on the dataset doc plus a one-shot `datasets:backfillRowCounts` migration for existing data. Contributors who pull main and run `make dev` get the new schema via the existing convex-push step, but curated seed datasets never receive writes, so the self-heal in the row mutations never fires for them — those cards keep showing the (capped at 5) preview-length fallback until someone remembers to run the backfill manually. Hooks the migration into `make dev` after convex-push. The mutation is idempotent (re-runs report `patched: 0, alreadyCorrect: N`) so there's no cost to running it every dev start. Uses the same env-var-only invocation shape as seed-public-datasets to avoid the Windows cmd issue where the `|` in the admin key gets parsed as a shell pipe when passed via --admin-key on the command line. --- makefiles/Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/makefiles/Makefile b/makefiles/Makefile index 3284ccc..c855d88 100644 --- a/makefiles/Makefile +++ b/makefiles/Makefile @@ -1,6 +1,6 @@ SHELL := /usr/bin/env bash -.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets ensure-admin-key install-deps +.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets backfill-row-counts ensure-admin-key install-deps all: dev @@ -20,6 +20,7 @@ dev: validate-dev-env install-deps $(MAKE) ensure-admin-key $(MAKE) convex-env $(MAKE) convex-push + $(MAKE) backfill-row-counts docker compose -f docker-compose.dev.yml up --build -d @echo "" @echo "BigSet is ready!" @@ -146,6 +147,20 @@ seed-public-datasets: @test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; } @cd frontend && node ../scripts/with-root-env.mjs npx convex run publicSeed:seedPublicDatasets +# One-shot idempotent migration: ensure every dataset doc has an accurate +# `rowCount` field (the field the dashboard card footer reads). Hooked +# into `make dev` so contributors pulling a branch that adds the field +# don't have to remember to run it manually. Re-running on a fully +# migrated DB reports `patched: 0, alreadyCorrect: N`. +# +# Matches the `seed-public-datasets` invocation shape (no --admin-key flag). +# `with-root-env.mjs` injects CONVEX_SELF_HOSTED_ADMIN_KEY into the env so +# the convex CLI picks it up automatically — avoids the Windows-cmd issue +# where the `|` in the admin key gets parsed as a shell pipe. +backfill-row-counts: + @test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; } + @cd frontend && node ../scripts/with-root-env.mjs npx convex run datasets:backfillRowCounts + down: docker compose -f docker-compose.dev.yml down