Skip to content

Conversation

@jaypatrick
Copy link
Owner

Summary

  • Add PostgreSQL as the default database provider for Prisma ORM
  • Configure Docker Compose with PostgreSQL 17 Alpine service and health checks
  • Add optional pg driver adapter support for connection pooling in PrismaStorageAdapter

Changes

  • Prisma Schema: Updated to use PostgreSQL as default provider
  • Dependencies: Added pg driver package for PostgreSQL connections
  • Docker Compose: Added PostgreSQL service with persistent volume and health checks
  • PrismaStorageAdapter: Added support for @prisma/adapter-pg with connection pooling (opt-in via USE_PG_ADAPTER=true)
  • Migrations: Created PostgreSQL-specific migration files in migrations/postgresql/
  • Tasks: Added db:migrate:deploy, db:migrate:reset, db:seed commands

Test plan

  • Start PostgreSQL with docker-compose up -d postgres
  • Run deno task db:push to sync schema
  • Run deno task db:generate to generate Prisma client
  • Run deno task dev and verify database connectivity
  • Optionally test with USE_PG_ADAPTER=true for connection pooling

🤖 Generated with Claude Code

- 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>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 2, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
adblock-compiler 25443cb Feb 02 2026, 07:09 PM

@jaypatrick
Copy link
Owner Author

@copilot fix the lint error

Copy link

Copilot AI commented Feb 2, 2026

@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.

Copilot AI and others added 2 commits February 2, 2026 04:25
Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
Fix lint error: prefix unused catch variable with underscore
Copy link

Copilot AI left a 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.yml plus corresponding environment examples and Prisma tasks (db:migrate:*, db:seed).
  • Extended PrismaStorageAdapter to optionally use the @prisma/adapter-pg + pg pool when USE_PG_ADAPTER=true, and added Postgres-specific SQL migrations under migrations/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.

Comment on lines +29 to +32
* 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';
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
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>
@jaypatrick jaypatrick closed this Feb 3, 2026
@jaypatrick jaypatrick deleted the feature/prisma-postgresql-support branch February 3, 2026 00:56
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.

2 participants