Database Setup
PageBridge stores search analytics data in PostgreSQL using Drizzle ORM. Here is how to configure your database.
Local development with Docker
The quickest way to get started is with Docker:
docker run -d --name pagebridge-db \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=pagebridge \
-p 5432:5432 \
postgres:16Or use the included Docker Compose file if working from the monorepo:
docker compose up -dSet your connection string:
DATABASE_URL='postgresql://postgres:postgres@localhost:5432/pagebridge'Hosted database providers
For production, use a hosted PostgreSQL provider:
- Neon — Serverless Postgres with branching. Free tier available.
- Supabase — Hosted Postgres with a generous free tier.
- Railway — Simple cloud Postgres provisioning.
- Vercel Postgres — Integrated with Vercel deployments.
Use the connection string from your provider:
DATABASE_URL='postgresql://user:password@host:5432/dbname?sslmode=require'Pushing the schema
PageBridge uses Drizzle ORM for schema management. Push the schema to create the required tables:
# From the monorepo root
pnpm db:push
# Or directly with drizzle-kit
pnpm drizzle-kit pushDatabase tables
PageBridge creates the following tables:
| Table | Purpose |
|---|---|
searchAnalytics | Page-level search metrics (clicks, impressions, CTR, position) per day |
queryAnalytics | Query-level search metrics per page per day |
syncLog | History of sync executions with status and row counts |
pageIndexStatus | Cached Google index inspection results (24h TTL) |
unmatchDiagnostics | Diagnostic data for URLs that could not be matched to Sanity documents |
Exploring with Drizzle Studio
You can browse your data with the built-in Drizzle Studio UI:
pnpm db:studioThis opens a web interface at https://local.drizzle.studio where you can view and query all tables.
Running migrations
If you need migration files (for example, in a CI pipeline), generate and run them with:
# Generate migration files
pnpm db:generate
# Run pending migrations
pnpm db:migrate
# Or run migrations automatically before a sync
pagebridge sync --site sc-domain:example.com --migrateThe --migrate flag on the sync and diagnose commands will automatically run any pending migrations before executing the command.