-
Notifications
You must be signed in to change notification settings - Fork 0
Add PostgreSQL support for Prisma storage #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Update Prisma schema to use PostgreSQL as default provider - Add pg driver package for PostgreSQL connections - Add PostgreSQL service to docker-compose with health checks - Create PostgreSQL-specific migration files - Update PrismaStorageAdapter with optional pg driver adapter for connection pooling - Add new database tasks (migrate:deploy, migrate:reset, seed) - Update .env.example with PostgreSQL configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
adblock-compiler | 25443cb | Feb 02 2026, 07:09 PM |
|
@copilot fix the lint error |
|
@jaypatrick I've opened a new pull request, #246, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
Fix lint error: prefix unused catch variable with underscore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR switches the Prisma-based storage to use PostgreSQL as the default backend, adds a Dockerized Postgres setup, and introduces optional connection pooling via @prisma/adapter-pg and pg.
Changes:
- Updated Prisma storage configuration and schema to treat PostgreSQL as the default provider and adjusted defaults for
DATABASE_URL. - Added a PostgreSQL 17 Alpine service in
docker-compose.ymlplus corresponding environment examples and Prisma tasks (db:migrate:*,db:seed). - Extended
PrismaStorageAdapterto optionally use the@prisma/adapter-pg+pgpool whenUSE_PG_ADAPTER=true, and added Postgres-specific SQL migrations undermigrations/postgresql/.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/storage/PrismaStorageAdapter.ts |
Adds a PostgreSQL-focused default DATABASE_URL, detects Postgres URLs, and conditionally wires up the pg pool + @prisma/adapter-pg adapter when USE_PG_ADAPTER=true, falling back to the standard PrismaClient and improving logging (including masking credentials). |
prisma/schema.prisma |
Switches the datasource provider to postgresql and updates header comments and usage examples to make PostgreSQL the documented default while still supporting SQLite and MongoDB via provider changes. |
prisma/prisma.config.ts |
Configures Prisma to default its datasource URL to a local PostgreSQL instance, keeping the value overridable via process.env.DATABASE_URL. |
migrations/postgresql/0001_init.sql |
Defines PostgreSQL DDL for the main storage tables (storage_entries, filter_cache, compilation_metadata, source_snapshots, source_health, source_attempts) aligned with the Prisma models and using TIMESTAMP WITH TIME ZONE and appropriate indexes. |
migrations/postgresql/0002_deployment_history.sql |
Adds PostgreSQL DDL for deployment_history and deployment_counter tables mirroring the existing D1/SQLite structures, enabling deployment tracking on Postgres. |
docker-compose.yml |
Introduces a postgres service (PostgreSQL 17-alpine) with health checks and a persistent volume, wires the adblock-compiler service to it via DATABASE_URL, and adds an explicit dependency on a healthy Postgres container. |
deno.json |
Adds Prisma-related tasks for migrating and seeding (db:migrate:deploy, db:migrate:reset, db:seed) and an npm import mapping for the pg driver to support the new adapter. |
.env.example |
Updates the default DATABASE_URL and related comments to point to PostgreSQL (local and Docker), and introduces POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB variables for the docker-compose setup. |
| * Default PostgreSQL database URL | ||
| * For local development, connects to localhost PostgreSQL instance | ||
| */ | ||
| const DEFAULT_DATABASE_URL = 'file:./data/adblock.db'; | ||
| const DEFAULT_DATABASE_URL = 'postgresql://adblock:adblock@localhost:5432/adblock'; |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc a few lines below still describes this adapter as "Default storage backend using Prisma ORM with SQLite", but the default provider and DEFAULT_DATABASE_URL here are now PostgreSQL. Please update that class-level description to call out PostgreSQL as the default (and adjust the supported-databases wording if needed) so the documentation matches the actual behavior.
Update prisma.config.ts to use DIRECT_DATABASE_URL environment variable for direct database connections, allowing separation from pooled connections. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Changes
pgdriver package for PostgreSQL connections@prisma/adapter-pgwith connection pooling (opt-in viaUSE_PG_ADAPTER=true)migrations/postgresql/db:migrate:deploy,db:migrate:reset,db:seedcommandsTest plan
docker-compose up -d postgresdeno task db:pushto sync schemadeno task db:generateto generate Prisma clientdeno task devand verify database connectivityUSE_PG_ADAPTER=truefor connection pooling🤖 Generated with Claude Code