From c6dfd4191dfae327dd8e33ee57117e4fb3135757 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 11 Nov 2026 10:26:25 +0000 Subject: [PATCH 1/2] fix: migrate the database with the installed Better Auth The db:generate and db:migrate scripts call @better-auth/cli, which is abandoned at 1.4.21 while the app runs better-auth 1.7.7. The old CLI's migration planner builds SQL that Postgres rejects, so schema changes never reached the database: error: type "oauthRefreshToken_authorizationCodeId_idx" does not exist db:migrate now runs scripts/migrate.js, which uses the installed library, seeds the planner client, and is what the Heroku release phase already runs. db:generate is removed: the 1.7 CLI reports schema status instead of writing SQL, and nothing reads the files it used to produce. The e2e job no longer runs migrations twice. --- .github/workflows/ci.yml | 3 --- AGENTS.md | 2 -- README.md | 1 - package.json | 3 +-- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b8d8b..ab786d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,7 +111,6 @@ jobs: with: node-version-file: ".nvmrc" - run: npm ci - - run: npm run db:generate - run: npm run db:migrate - run: npm test -- --disable-coverage @@ -149,9 +148,7 @@ jobs: node-version-file: ".nvmrc" - run: npm ci - run: npx playwright install chromium-headless-shell - - run: npm run db:generate - run: npm run db:migrate - - run: node scripts/migrate.js - run: | node src/index.js > server.log 2>&1 & for i in {1..30}; do diff --git a/AGENTS.md b/AGENTS.md index 4c4a71e..8d9f9e6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,7 +32,6 @@ Authentication/profile prototype for Codebar using [Better Auth](https://www.bet 3. For new setup: ```sh npm ci - npm run db:generate npm run db:migrate npm run dev ``` @@ -56,7 +55,6 @@ See [docs/heroku-setup.md](docs/heroku-setup.md) for initial Heroku setup and [d **Database:** -- `npm run db:generate` - Generate Better Auth database schema - `npm run db:migrate` - Run database migrations - `rm auth.db` - Delete local database to start fresh diff --git a/README.md b/README.md index 2f1b4ed..fbb716e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ For a new run the following: ```sh npm ci -npm run db:generate npm run db:migrate npm run dev ``` diff --git a/package.json b/package.json index c975481..69e7d1e 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ }, "scripts": { "dev": "scripts/container.sh ensure && node --watch src/index.js", - "db:generate": "npx @better-auth/cli generate --yes", - "db:migrate": "npx @better-auth/cli migrate --yes", + "db:migrate": "node scripts/migrate.js", "fallow": "fallow", "prettier:check": "prettier --check '**/*.{js,css,md,yml}'", "prettier:write": "prettier --write '**/*.{js,css,md,yml}'", From 6406e00c9deed8d4a1e9fa81529626414b458844 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 11 Nov 2026 11:57:13 +0000 Subject: [PATCH 2/2] fix: start the local Postgres container before migrating `db:migrate` now runs `scripts/container.sh ensure` first, so the documented fresh-setup order (migrate, then `npm run dev`) works on a machine that has never started the dev database. The script exits 0 where apple/container is not installed, so CI is unchanged. AGENTS.md no longer claims local development uses SQLite. It documents the container reset procedure, and records that `db:migrate` seeds the planner OAuth client. --- AGENTS.md | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 8d9f9e6..7f6da9c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -55,10 +55,10 @@ See [docs/heroku-setup.md](docs/heroku-setup.md) for initial Heroku setup and [d **Database:** -- `npm run db:migrate` - Run database migrations -- `rm auth.db` - Delete local database to start fresh +- `npm run db:migrate` - Run database migrations and seed the planner OAuth client +- `scripts/container.sh destroy` - Delete the local Postgres container and its data to start fresh -**Local development uses SQLite** (`./auth.db` file). No database server needed. +**Local development and tests use a Postgres container** (`scripts/container.sh`, port 5433, started by `npm run dev` and `pretest`). **CI and production use PostgreSQL** (configured via `DATABASE_URL` environment variable). **Code quality:** diff --git a/package.json b/package.json index 69e7d1e..f25738b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "scripts": { "dev": "scripts/container.sh ensure && node --watch src/index.js", - "db:migrate": "node scripts/migrate.js", + "db:migrate": "scripts/container.sh ensure && node scripts/migrate.js", "fallow": "fallow", "prettier:check": "prettier --check '**/*.{js,css,md,yml}'", "prettier:write": "prettier --write '**/*.{js,css,md,yml}'",