Skip to content

Commit a796bab

Browse files
Auto-run rowCount backfill during make dev
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.
1 parent 3222058 commit a796bab

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

makefiles/Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL := /usr/bin/env bash
22

3-
.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets ensure-admin-key install-deps
3+
.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets backfill-row-counts ensure-admin-key install-deps
44

55
all: dev
66

@@ -20,6 +20,7 @@ dev: validate-dev-env install-deps
2020
$(MAKE) ensure-admin-key
2121
$(MAKE) convex-env
2222
$(MAKE) convex-push
23+
$(MAKE) backfill-row-counts
2324
docker compose -f docker-compose.dev.yml up --build -d
2425
@echo ""
2526
@echo "BigSet is ready!"
@@ -146,6 +147,20 @@ seed-public-datasets:
146147
@test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; }
147148
@cd frontend && node ../scripts/with-root-env.mjs npx convex run publicSeed:seedPublicDatasets
148149

150+
# One-shot idempotent migration: ensure every dataset doc has an accurate
151+
# `rowCount` field (the field the dashboard card footer reads). Hooked
152+
# into `make dev` so contributors pulling a branch that adds the field
153+
# don't have to remember to run it manually. Re-running on a fully
154+
# migrated DB reports `patched: 0, alreadyCorrect: N`.
155+
#
156+
# Matches the `seed-public-datasets` invocation shape (no --admin-key flag).
157+
# `with-root-env.mjs` injects CONVEX_SELF_HOSTED_ADMIN_KEY into the env so
158+
# the convex CLI picks it up automatically — avoids the Windows-cmd issue
159+
# where the `|` in the admin key gets parsed as a shell pipe.
160+
backfill-row-counts:
161+
@test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; }
162+
@cd frontend && node ../scripts/with-root-env.mjs npx convex run datasets:backfillRowCounts
163+
149164
down:
150165
docker compose -f docker-compose.dev.yml down
151166

0 commit comments

Comments
 (0)