worker/migrations

The schema of jevstrudel, the site's D1 database (the Worker's DB binding), as numbered SQL files that wrangler applies in order, each once per database. It records what it has applied in the database's own d1_migrations table.

FileWhat it adds
0001_votes.sqlvotes: the "do you agree with Jev?" counts, one row per (a, b, pick) (src/votes.ts).
0002_accounts.sqlusers, credentials (passkeys), sessions (token hashes) and auth_challenges (src/accounts-store.ts, for src/auth.ts), and radio_plays, a signed-in listener's radio history (src/radio.ts).
0003_listening.sqlreactions (every listener's 🔥/😴, a count per song, section and reaction), performances (one play of a song, for a replay link) and performance_segments (what each jev() played per segment: Jev's decision history) (src/listening.ts).
0004_listener_content.sqllistener_songs, song_revisions (each with Jev's screening verdict and the critic's score), covers (records; the images are R2), comments, pitches, and content_jobs, the screening and scoring Jev still owes, kept by triggers (src/content-store.ts, for src/content.ts and src/content-jobs.ts).
0005_pitch_votes.sqlpitch_votes, one row per account per pitch it voted for, and listener_songs.pitch, the pitch a listener song answers, set by its author (src/content-store.ts, for src/content.ts). Who voted for what is public, like every row.
0006_performance_players.sqlperformances.user_id, the account that played a take (signed in; public, set null when the account is deleted), and performances.recorded_at, when to the millisecond (takes from before are dated noon UTC of their day) (src/listening-store.ts, for src/listening.ts, src/data.ts and src/activity.ts).

Every table is public to read, people included, on the jev panel's data tab (src/data.ts), except the columns that are secrets: a session's id_hash, a credential's id and public_key, and every auth_challenges row, which are counted and dated only. jevstrudel is a playground shared in the Jev community; that is what it stores, shown.

Where they are applied:

  • buck2 run //:dev and //:preview apply them to their local databases on every start (tools/dev/migrate.mjs).
  • nix run .#deploy applies them to the real database before publishing the Worker (tools/deploy/resources.mjs).
  • The tests apply them to an in-memory SQLite (worker/test/d1.ts).

To add one: the next number, a lowercase name, wrangler d1 migrations create jevstrudel <name> from worker/ (or write the file by hand), then restart //:dev, or apply it to the running one with wrangler d1 migrations apply jevstrudel --local --env dev --config worker/wrangler.json from the repo root.

To look at the local data: wrangler d1 execute jevstrudel --local --env dev --config worker/wrangler.json --command "SELECT * FROM votes".