Prisma PostgreSQL Setup

A guide to switching your Prisma environment to PostgreSQL. This guide covers the essential XAMPP configuration required to enable the PostgreSQL drivers.

Configuration Workflow

Standard setup procedure.

  1. 1 Enable pgsql extensions in XAMPP.
  2. 2 Set provider to postgresql in schema.prisma.
  3. 3 Update connection string in .env.
  4. 4 Run migrations.

XAMPP Requirement

XAMPP has PostgreSQL drivers disabled by default. You must enable them in php.ini.

// php/php.ini

extension=pgsql

extension=pdo_pgsql

* Remove the semicolon (;) to uncomment. Restart Apache after saving.


Schema Configuration

Define your datasource in schema.prisma.

schema.prisma
generator client {
    provider = "prisma-client-js"
}
    
datasource db {
    provider = "postgresql"
}

Note: By default, Prisma PHP initializes with PostgreSQL settings.

Environment Variables

Configure your connection string in the .env file. Note that PostgreSQL URLs require a specific schema (usually public).

.env
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public"

Connection Parameters

USER Database username (e.g., postgres)
PASSWORD Your database password
HOST Server IP (e.g., localhost)
PORT Default is 5432
schema Defaults to 'public'

Setup Complete

Once your php.ini is updated and your environment variables are set, you are ready to push your schema to the database.

Go to Prisma Command