CLI utilities for managing PaxMiner MySQL data that powers the map and other apps. This workspace holds the Drizzle schema, Docker Compose for local MySQL, and scripts to back up production data and reseed a local database.
- Create
.env.productionwithMYSQL_URLthat can read the production PaxMiner database. This is used by backup/pull commands. - Create
.env.localwithMYSQL_URLfor your local MySQL instance (used by migrate/seed/reset). IncludeMYSQL_ROOT_PASSWORDif you change the Docker defaults. - You can point a command at a different env file by setting
MYSQL_ENV_FILE=<file>.
Example .env.local that matches the Docker defaults:
MYSQL_URL=mysql://f3muletown:local-f3-password@localhost:3307/f3muletown
MYSQL_ROOT_PASSWORD=local-root-password
- Start MySQL locally (port 3307):
pnpm --filter f3-nation-admin db:up - Pull the latest production snapshot into
.data/backups/<timestamp>:pnpm --filter f3-nation-admin db:backup - Apply the schema to your local DB (creates DB/user if missing):
pnpm --filter f3-nation-admin db:migrate - Seed your local DB from the newest backup:
pnpm --filter f3-nation-admin db:seed - Do everything in one shot (backup → fresh container → migrate → seed):
pnpm --filter f3-nation-admin db:local:setup
After seeding, point any app that needs PaxMiner data at the local MYSQL_URL.
db:up/db:down: Start/stop the local MySQL container.db:downremoves the volume, so you get a clean slate the next time you start.db:backup: Export every table listed indrizzle/meta/0000_snapshot.jsonto.data/backups/<timestamp>/*.jsonusing.env.production.db:seed: Load the latest backup into the DB targeted by.env.local, normalizing date/datetime/json columns as needed.db:migrate: Guarded Drizzle push against a local host; also ensures the database/user exist via the root credentials.db:pull: Refresh the Drizzle snapshot from production so backups and seeds stay in sync with the real schema.db:reset: Truncate all PaxMiner tables in the target DB; intended for local-only use.migrate:user:posts: Remap Slack user IDs across PaxMiner tables (with conflict checks). Usemigrate:user:posts:localormigrate:user:posts:prodto target the right environment.
Use these to add or remove a single pax’s attendance for a specific AO/date. The scripts guard against missing backblasts and double-entry.
- Add a missing record:
pnpm --filter f3-nation-admin attendance:ensure <slack-user-id> <ao-channel-id> <YYYY-MM-DD> - Remove a mistaken record:
pnpm --filter f3-nation-admin attendance:remove <slack-user-id> <ao-channel-id> <YYYY-MM-DD> - Target prod/local explicitly with
attendance:ensure:prod/attendance:remove:prodor the:localvariants; both respectMYSQL_ENV_FILE. - Find Slack user IDs in your workspace’s admin dashboard, e.g.
https://f3muletown.slack.com/admin(replacef3muletownwith your region).
- Backups/seeds rely on the Drizzle snapshot to know which tables to process. Run
db:pullwhen the production schema changes. - Scripts that mutate data refuse to run against non-local hosts; double-check
MYSQL_URLbefore running anything destructive. - Backup JSON files stay under
.data/backups/inside this workspace and are gitignored.