Skip to content

Switch from @astrojs/db to drizzle#45

Merged
RobbieTheWagner merged 2 commits intomainfrom
drizzle
Mar 27, 2026
Merged

Switch from @astrojs/db to drizzle#45
RobbieTheWagner merged 2 commits intomainfrom
drizzle

Conversation

@RobbieTheWagner
Copy link
Copy Markdown
Member

@RobbieTheWagner RobbieTheWagner commented Mar 27, 2026

Summary by CodeRabbit

  • Refactor

    • Migrated database backend to Drizzle ORM (Turso/libSQL) and removed the previous Astro DB integration.
  • Chores

    • Updated build scripts to remove remote build flag and refreshed dev tooling/scripts (including DB push/studio/seed commands).
    • Replaced database environment variables with new names; CI updated to supply them.
  • New Content

    • Added new episode guest and sponsor entries.
  • Documentation

    • Docs updated to reflect build, schema, and tooling changes.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
starpod Ready Ready Preview, Comment Mar 27, 2026 2:25pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 436cef45-976d-4221-ae23-2d9aca7d2622

📥 Commits

Reviewing files that changed from the base of the PR and between 7e02eb2 and a48fe7e.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

Migrates from Astro DB to Drizzle ORM/Turso: removes Astro DB integration, adds Drizzle schema and config, introduces a DB factory, updates seed and page code to use Drizzle, updates data and package scripts, and adjusts CI and docs to use new environment variables.

Changes

Cohort / File(s) Summary
Build & Dependency Configuration
astro.config.mjs, package.json, drizzle.config.ts
Removed @astrojs/db integration; updated build script to drop --remote; added Drizzle/Turso deps and Drizzle Kit config; added db:push/db:studio scripts and tsx/dotenv tooling.
Schema Migration
db/config.ts, db/schema.ts, db/index.ts
Deleted Astro DB db/config.ts; added db/schema.ts with Drizzle sqlite table definitions for Episode/Person/HostOrGuest/Sponsor/SponsorForEpisode; added db/index.ts with createDb(url, authToken) and Database type.
Seed & Runtime
db/seed.ts, src/pages/[episode].astro
Rewrote seed to use createDb(process.env.ASTRO_DB_REMOTE_URL, process.env.ASTRO_DB_APP_TOKEN) and top-level execution; replaced astro:db imports in page with Drizzle imports and per-request createDb(...) usage.
Data Content
db/data/people.ts, db/data/people-per-episode.ts, db/data/sponsors-per-episode.ts
Added three people entries and three episode-to-people mappings; added/activated three episode-to-sponsor mappings linking to sponsor warp.
CI & Workflows
.github/workflows/ci.yml
Injected ASTRO_DB_REMOTE_URL and ASTRO_DB_APP_TOKEN into Playwright job from secrets.
Documentation
CLAUDE.md
Replaced Astro DB terminology with Drizzle/Turso, updated build instructions, schema/config paths (db/schema.ts, db/index.ts), and environment-variable guidance (ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN).

Sequence Diagram(s)

sequenceDiagram
  participant Page as Page ([episode].astro)
  participant Seed as Seed (db/seed.ts)
  participant DBFactory as DB Factory (db/index.ts)
  participant Remote as Remote DB (Turso/libSQL)

  Page->>DBFactory: createDb(ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN)
  DBFactory->>Remote: open connection (url, authToken)
  Page->>Remote: run queries via Drizzle ORM

  Seed->>DBFactory: createDb(ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN)
  DBFactory->>Remote: open connection (url, authToken)
  Seed->>Remote: insert seed data / relations
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Skipping through schema, nibbling seeds anew,

Astro off the lawn, Drizzle paints the view.
Three guests hop in, sponsors bring the warp,
Seeds take root, connections snap to sharp.
A rabbit cheers—migration’s through! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: migrating from @astrojs/db to drizzle ORM, which is the main focus across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drizzle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
db/seed.ts (2)

20-23: Consider validating environment variables before use.

The non-null assertions (!) will cause a runtime error with an unclear message if the environment variables are missing. Adding explicit validation would provide better error messages.

🛡️ Proposed validation
+const url = process.env.ASTRO_DB_REMOTE_URL;
+const token = process.env.ASTRO_DB_APP_TOKEN;
+
+if (!url || !token) {
+  console.error('Missing required environment variables: ASTRO_DB_REMOTE_URL and/or ASTRO_DB_APP_TOKEN');
+  process.exit(1);
+}
+
-const db = createDb(
-  process.env.ASTRO_DB_REMOTE_URL!,
-  process.env.ASTRO_DB_APP_TOKEN!
-);
+const db = createDb(url, token);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@db/seed.ts` around lines 20 - 23, The code calls createDb(...) using non-null
assertions on process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN
which will throw unclear runtime errors if those env vars are missing; add
explicit validation in db/seed.ts before calling createDb: check
process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN, and if
either is falsy, throw or log a descriptive error (e.g., "Missing
ASTRO_DB_REMOTE_URL" / "Missing ASTRO_DB_APP_TOKEN") and exit so createDb is
only invoked with validated values. Ensure you reference the same symbols
(createDb, ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN) so the guard is colocated
with the current call.

26-32: Replace the as any type cast with a more specific assertion.

The people data structure matches the Person schema fields, but using as any bypasses TypeScript's type checking unnecessarily. Consider using a more specific type assertion or ensuring the inferred type is compatible with Drizzle ORM's .values() method to maintain type safety.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@db/seed.ts` around lines 26 - 32, The current call to
db.insert(Person).values(people as any) uses an unsafe any cast; replace it with
a specific insert type so TypeScript validates the rows — e.g., import and use
the Drizzle insert type (or define a PersonInsert type) and cast people to
PersonInsert[] (or the appropriate Array<InsertTypeForPerson>) before passing to
.values(), ensuring the types align with the Person table and preserving type
safety for db.insert(Person).values(...).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@drizzle.config.ts`:
- Around line 1-11: The config file exports defineConfig and reads
process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN but never
loads .env, so drizzle-kit runs may see undefined values; fix by importing
dotenv (e.g., require('dotenv/config') or import 'dotenv/config') at the top of
drizzle.config.ts before the default export so dbCredentials (the
ASTRO_DB_REMOTE_URL and ASTRO_DB_APP_TOKEN references) are populated when
defineConfig executes.

---

Nitpick comments:
In `@db/seed.ts`:
- Around line 20-23: The code calls createDb(...) using non-null assertions on
process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN which will
throw unclear runtime errors if those env vars are missing; add explicit
validation in db/seed.ts before calling createDb: check
process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN, and if
either is falsy, throw or log a descriptive error (e.g., "Missing
ASTRO_DB_REMOTE_URL" / "Missing ASTRO_DB_APP_TOKEN") and exit so createDb is
only invoked with validated values. Ensure you reference the same symbols
(createDb, ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN) so the guard is colocated
with the current call.
- Around line 26-32: The current call to db.insert(Person).values(people as any)
uses an unsafe any cast; replace it with a specific insert type so TypeScript
validates the rows — e.g., import and use the Drizzle insert type (or define a
PersonInsert type) and cast people to PersonInsert[] (or the appropriate
Array<InsertTypeForPerson>) before passing to .values(), ensuring the types
align with the Person table and preserving type safety for
db.insert(Person).values(...).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e958a22e-4e5c-4ace-927d-681ee83ad54a

📥 Commits

Reviewing files that changed from the base of the PR and between 37959d0 and 7e02eb2.

⛔ Files ignored due to path filters (4)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • src/img/people/dthompsondev.jpg is excluded by !**/*.jpg
  • src/img/people/leonnoel.jpg is excluded by !**/*.jpg
  • src/img/people/wattenberger.jpg is excluded by !**/*.jpg
📒 Files selected for processing (12)
  • CLAUDE.md
  • astro.config.mjs
  • db/config.ts
  • db/data/people-per-episode.ts
  • db/data/people.ts
  • db/data/sponsors-per-episode.ts
  • db/index.ts
  • db/schema.ts
  • db/seed.ts
  • drizzle.config.ts
  • package.json
  • src/pages/[episode].astro
💤 Files with no reviewable changes (2)
  • astro.config.mjs
  • db/config.ts

Comment on lines +1 to +11
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
schema: './db/schema.ts',
out: './drizzle',
dialect: 'turso',
dbCredentials: {
url: process.env.ASTRO_DB_REMOTE_URL!,
authToken: process.env.ASTRO_DB_APP_TOKEN!
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if drizzle-kit documentation mentions automatic .env loading
# and verify the current setup works

# Check if there's a .env or .env.local file in the repo
fd -t f '\.env' --max-depth 1

# Check if any other config files load dotenv
rg -n "dotenv" --type ts --type js -g '!node_modules'

Repository: shipshapecode/starpod

Length of output: 216


🏁 Script executed:

# Check package.json for drizzle scripts and configuration
cat -n package.json | grep -A 20 '"scripts"'

Repository: shipshapecode/starpod

Length of output: 877


🏁 Script executed:

# Look for any references to how drizzle-kit is invoked
rg -n "drizzle" package.json -A 2 -B 2

Repository: shipshapecode/starpod

Length of output: 641


🏁 Script executed:

# Check if there's a .env file referenced elsewhere or if env vars are set differently
find . -name ".env*" -o -name "*.env*" 2>/dev/null | head -20

Repository: shipshapecode/starpod

Length of output: 47


🏁 Script executed:

# Check the actual drizzle.config.ts more carefully for any dotenv loading
cat -n drizzle.config.ts

Repository: shipshapecode/starpod

Length of output: 401


🏁 Script executed:

# Search for CI/CD configurations that might set environment variables
fd -t f "\.github|\.gitlab|\.circleci|github|gitlab|circleci" --max-depth 2 2>/dev/null | head -20

Repository: shipshapecode/starpod

Length of output: 47


🏁 Script executed:

# Check .gitignore to see if .env files are ignored
cat -n .gitignore 2>/dev/null | grep -i "env"

Repository: shipshapecode/starpod

Length of output: 130


🏁 Script executed:

# Look for any Vercel or deployment configuration
fd -t f "vercel.json|netlify.toml|astro.config|environment" --max-depth 2

Repository: shipshapecode/starpod

Length of output: 81


🌐 Web query:

drizzle-kit .env automatic loading environment variables

💡 Result:

Drizzle-kit does not automatically load environment variables from .env files by default. Users must manually load them in the drizzle.config.ts (or .js) file using a library like dotenv. To enable .env loading: 1. Install dotenv: npm i -D dotenv 2. In drizzle.config.ts: import * as dotenv from "dotenv"; dotenv.config({ path: ".env.local" }); // or appropriate .env file import type { Config } from "drizzle-kit"; export default { schema: "./src/db/schema.ts", out: "./drizzle", dialect: "postgresql", dbCredentials: { url: process.env.DATABASE_URL!, }, } satisfies Config; For Next.js projects, use @next/env instead: import { loadEnvConfig } from "@next/env"; loadEnvConfig("./"); Alternative approaches: - Use Node.js --env-file flag (Node v20.6+): node --env-file=.env.local ./node_modules/drizzle-kit/bin.cjs generate - Prefix commands: dotenv -e .env.local -- drizzle-kit generate A GitHub discussion (#3405) from Nov 2024 announced planned built-in support for automatic .env loading (including .env*, .env.local based on NODE_ENV, --env-file, --no-env flags), using dotenvx. Some users report it "working out of the box" in recent versions (e.g., 0.30.5+), and logs show "Env file: .env.development.local", but official docs do not confirm full implementation as of 2026-03-27. Check latest changelog or test npx drizzle-kit push to verify if automatic loading is active in your version. Official docs recommend manual dotenv import for dbCredentials.

Citations:


Add dotenv loading to drizzle.config.ts to ensure environment variables are available when running drizzle-kit commands.

Drizzle Kit doesn't automatically load .env files. The configuration references process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN without loading them, which means these values will be undefined unless set externally (e.g., in CI/CD or shell environment). This is inconsistent with db/seed.ts, which already imports dotenv/config.

Solution: Add dotenv import
+import 'dotenv/config';
 import { defineConfig } from 'drizzle-kit';
 
 export default defineConfig({
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@drizzle.config.ts` around lines 1 - 11, The config file exports defineConfig
and reads process.env.ASTRO_DB_REMOTE_URL and process.env.ASTRO_DB_APP_TOKEN but
never loads .env, so drizzle-kit runs may see undefined values; fix by importing
dotenv (e.g., require('dotenv/config') or import 'dotenv/config') at the top of
drizzle.config.ts before the default export so dbCredentials (the
ASTRO_DB_REMOTE_URL and ASTRO_DB_APP_TOKEN references) are populated when
defineConfig executes.

@RobbieTheWagner RobbieTheWagner merged commit 3379617 into main Mar 27, 2026
5 checks passed
@RobbieTheWagner RobbieTheWagner deleted the drizzle branch March 27, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant