Goatside

Database

Turso, migrations, local development and backups.

Goatside keeps everything in one Turso database. The schema and its migrations are written with Drizzle and live in packages/db.

Migrations

Vercel doesn't migrate the database, so an update that changes the tables needs its migrations run too. You can run them from GitHub Actions or from your computer. If a deploy is ahead of its database, Goatside opens on a page that says how many migrations haven't run, instead of failing on every page.

Your URL and token

Both ways need your database's URL and token.

They're your Vercel project's TURSO_DATABASE_URL and TURSO_AUTH_TOKEN. In the project, open Storage and select the database to see them. Or copy them into your clone with the Vercel CLI:

cd apps/goatside
vercel link    # first time only
vercel env pull .env.production.local --environment=production

Delete that file once you've used the values. Git ignores it, but it holds your production token.

With GitHub Actions

Your fork can apply migrations on every push to main, once the checks pass.

  1. Open your fork's Actions tab and enable workflows. GitHub turns them off on new forks, and until you do, nothing runs.
  2. Under Settings → Secrets and variables → Actions, add TURSO_DATABASE_URL and TURSO_AUTH_TOKEN as repository secrets.

To migrate without pushing, open CI on the Actions tab and choose Run workflow on main. Without the secrets, the migrate job skips its work and leaves a notice on the run.

Vercel deploys the same push on its own and can finish first. Until the migration lands, usually a minute or two, Goatside shows that it's waiting for it and checks again every 15 seconds. If you'd rather avoid that, run the migration by hand before you push.

From your computer

From your clone:

TURSO_DATABASE_URL=libsql://goatside-<you>.turso.io \
TURSO_AUTH_TOKEN=<token> \
pnpm db:migrate

Running it again is safe. It skips migrations that are already applied.

Without TURSO_DATABASE_URL, pnpm db:migrate targets the local database at http://127.0.0.1:8080. It doesn't read .env.local, so pass the URL every time you mean production.

What's set up on sign-in

Every successful sign-in makes sure your settings and default categories exist. It only adds what's missing, so it never undoes a rename or an archived category.

  • Spending categories: Food, Groceries, Transport, Bills, Subscriptions, Shopping, Health, Fun, Others.
  • Income categories: Salary, Freelance, Gifts, Others.

Locally

pnpm dev starts a local libSQL server on :8080 with the data in packages/db/.data/local.db. You can also run it alone with pnpm db:dev.

CommandWhat it does
pnpm db:migrateApplies migrations
pnpm db:generateWrites a new migration after you change packages/db/src/schema
pnpm db:studioOpens Drizzle Studio to browse the data

To try Goatside with three months of sample data, start a second local database and fill it. The demo script refuses remote URLs, and a database that already has entries.

turso dev --db-file packages/db/.data/demo.db --port 8090
TURSO_DATABASE_URL=http://127.0.0.1:8090 pnpm db:migrate
TURSO_DATABASE_URL=http://127.0.0.1:8090 pnpm --filter @workspace/db demo

Backups

Your ledger is only in your database, so keep a copy. Turso keeps point-in-time history you can restore from, and how far back depends on your plan. With the Turso CLI, you can also export the database as a SQLite file at any time:

turso db export goatside

For a spreadsheet of your entries, use Export on the Transactions page.

On this page