Skip to content

Commit fbe4964

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 0a86186 commit fbe4964

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,4 +1,4 @@
1-
.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets
1+
.PHONY: all dev validate-dev-env down clean convex-push convex-env seed-public-datasets backfill-row-counts
22

33
all: dev
44

@@ -12,6 +12,7 @@ dev: validate-dev-env
1212
done
1313
$(MAKE) convex-env
1414
$(MAKE) convex-push
15+
$(MAKE) backfill-row-counts
1516
@echo ""
1617
@echo "Ready!"
1718
@echo " App: http://localhost:3500"
@@ -70,6 +71,20 @@ seed-public-datasets:
7071
@test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; }
7172
@cd frontend && node ../scripts/with-root-env.mjs npx convex run publicSeed:seedPublicDatasets
7273

74+
# One-shot idempotent migration: ensure every dataset doc has an accurate
75+
# `rowCount` field (the field the dashboard card footer reads). Hooked
76+
# into `make dev` so contributors pulling a branch that adds the field
77+
# don't have to remember to run it manually. Re-running on a fully
78+
# migrated DB reports `patched: 0, alreadyCorrect: N`.
79+
#
80+
# Matches the `seed-public-datasets` invocation shape (no --admin-key flag).
81+
# `with-root-env.mjs` injects CONVEX_SELF_HOSTED_ADMIN_KEY into the env so
82+
# the convex CLI picks it up automatically — avoids the Windows-cmd issue
83+
# where the `|` in the admin key gets parsed as a shell pipe.
84+
backfill-row-counts:
85+
@test -f .env || { echo "Error: .env not found. Run: cp .env.example .env"; exit 1; }
86+
@cd frontend && node ../scripts/with-root-env.mjs npx convex run datasets:backfillRowCounts
87+
7388
down:
7489
docker compose -f docker-compose.dev.yml down
7590

0 commit comments

Comments
 (0)