Category

PostgreSQL

Explore our curated collection of articles, insights, and stories about PostgreSQL.

67 Articles
PostgreSQL

PostgreSQL 18 Docker: Fix Existing Volume Startup Errors

Separate a Docker mount failure from a PostgreSQL major upgrade, preserve the original volume and prove the restored database survives a restart.

11 min read
PostgreSQL

Drizzle D1: migrations do not match any local migration

Why drizzle-kit migrate on Cloudflare D1 works once and then rejects every migration it applied, with id and created_at undefined, and the version pair that makes repeat runs pass again.

7 min read
PostgreSQL

drizzle-seed reset() fails on drizzle-orm beta/rc: fix

Why plain npm install drizzle-seed breaks on a Drizzle v1 project, which seed version to pair with your drizzle-orm, and what reset() really sends to PostgreSQL.

7 min read
PostgreSQL

drizzle-kit/api: Dynamic require of "fs" is not supported

Get pushSchema, generateDrizzleJson and generateMigration importing from an ES module or a Vitest suite again: check your drizzle-kit version, upgrade, or fall back to createRequire.

7 min read
PostgreSQL

drizzle-kit migrate: relation "users" already exists

Get drizzle-kit migrate working on a database that drizzle-kit push created: why the first CREATE TABLE runs again, how to mark the old migrations as applied, and why IF NOT EXISTS only hides the problem.

9 min read
PostgreSQL

Prisma Nested Create Returns Undefined: Include the Relation

Separate missing response fields from missing database rows, and prove that a nested write succeeded before retrying it or changing the schema.

7 min read
PostgreSQL

Fix: Supabase local logs "Backend error" (and old 502s)

The same local Studio Logs pipeline, broken three different ways since 2024: here is which one you are on, and the fix for each.

8 min read
PostgreSQL

Drizzle: Object literal may only specify known properties

Get .values() and .set() accepting your nullable Drizzle columns again: which versions lose them, why a loose tsconfig is the trigger, and the workaround that does not help.

8 min read
PostgreSQL

Fix Prisma 'Unique constraint failed on the fields: (id)'

Prove in two queries that the id sequence is stuck behind your imported rows, reset it safely even on an empty table, and see why retrying seems to fix it.

8 min read
PostgreSQL

Drizzle: Cannot destructure property 'resourceArn' fix

Get drizzle-kit studio and migrate talking to Aurora through the AWS Data API again, and know which error comes next on current releases.

8 min read
PostgreSQL

drizzle-kit generate: Cannot find module .js under nodenext

Get drizzle-kit generate working in a "type": "module" project that writes .js extensions in its TypeScript imports, without dropping nodenext.

7 min read
PostgreSQL

Drizzle db.query drops pgSchema: relation does not exist

Get db.query.findMany() and findFirst() reading your custom Postgres schema again: which drizzle-orm versions drop the schema, why, and three tested ways out.

7 min read
PostgreSQL

Prisma "Ambiguous relation detected": name both relations

Turn a P1012 "Ambiguous relation detected" into a valid referral schema: what the validator compares, the second error naming uncovers, and three tested models.

8 min read
PostgreSQL

Drizzle "table name specified more than once" in nested with

Get a deep findMany({ with }) tree running again: how the 63-byte alias limit makes two Drizzle aliases identical, a pre-flight check, and two tested fixes.

8 min read
PostgreSQL

Fix Prisma "Could not figure out an ID in create" panic

Find which of the two empty-insert causes you have in one psql query, apply the one-line fix, and see why Prisma 7 returns null instead of crashing.

9 min read
PostgreSQL

Fix NeonDbError: Error connecting to database: fetch failed

Find out in one log line why Drizzle cannot reach Neon, why reads and writes fail together, and how to prove the connection works again.

9 min read
PostgreSQL

Fix Prisma v7 paths[1] must be of type string error

A step-by-step fix for the Prisma 7 startup crash, reproduced against Postgres, plus the driver-adapter error that follows it.

8 min read
PostgreSQL

Fix Prisma 42P01: table exists but raw query cannot find it

A catalog listing and a missing-table error can both be correct. Trace the name PostgreSQL resolves, preserve bound search values, and verify mapped tables.

7 min read
PostgreSQL

Fix Supabase CHARINDEX does not exist (SQLSTATE 42883)

Repair the email-to-username expression without adding columns or hiding trigger failures, with a PostgreSQL reproduction and signature checks.

8 min read
PostgreSQL

Drizzle TableLikeHasEmptySelection error in generic helpers

Keep your reusable Drizzle query helpers compiling on 0.45.4: why only generic code breaks, four workarounds that type-check, and what each one costs you.

8 min read
PostgreSQL

drizzle-kit: Cannot use import statement outside a module

Get drizzle-kit generate, push and migrate past an ES module import in your schema: find which loader and which Node defaults you have, then pick one of three fixes.

7 min read
PostgreSQL

Fix Can't resolve 'fs' When Importing pg in Next.js

Where a node-postgres Pool belongs in a Next.js app, why a Client Component import breaks the build, and how to prove one pool serves every request.

9 min read
PostgreSQL

Supabase db push: must be owner of table (SQLSTATE 42501)

Why a migration that runs fine locally is refused on the remote project, which owner fixes work from the postgres role today, and when only Supabase support can help.

7 min read
PostgreSQL

Drizzle: Offset is outside the bounds of the DataView

Make findFirst({ with }) return your PostGIS points again: why only nested relations crash, and three fixes tested against PostGIS 3.6.

8 min read
PostgreSQL

Keystone 6 Foreign Key NOT NULL on a Relationship Field

Turn a nullable Keystone relationship column into a NOT NULL foreign key, backfill the rows that block the push, and replace raw Prisma errors with clear messages.

7 min read
PostgreSQL

Fix drizzle-kit migrate Hanging After Using 'pg' Driver

Get a real error message, or a finished migration, out of a drizzle-kit migrate that sits on its last line: two causes you can rule out in a minute, and two ways to apply the migrations anyway.

8 min read
PostgreSQL

Prisma nested connect: syntax error at or near "ON"

Find out in one query whether your production PostgreSQL is too old for Prisma, then move the data to a supported server with pg_dump and pg_restore.

8 min read
PostgreSQL

Fix Drizzle Rollback: let the exception escape

Prove whether a swallowed manual rollback commits, then check the persisted rows after changing one catch handler.

8 min read
PostgreSQL

Supabase pgsodium_trg_mask_update: Fix Owner Error

Creating or editing a table in the Supabase dashboard throws a permission error that names a trigger you have never heard of. It is not a missing grant — it is Vault's pgsodium extension holding an event trigger your role does not own. Here is the workaround that keeps you working today and the fix that resets ownership for good.

8 min read
PostgreSQL

Fix ECONNREFUSED 127.0.0.1:5432 in GitHub Actions

Your Postgres service is healthy, yet the migration step cannot reach it. Pick the host that matches how the job runs, and make Sequelize read DATABASE_URL.

8 min read
PostgreSQL

Prisma $queryRaw TS2345: 'string' not assignable to Sql

Why a NestJS PrismaService rejects a template literal in brackets, three fixes that compile and run on Prisma 7, and the two errors that come next.

8 min read
PostgreSQL

Fix: TypeORM "array is not supported in postgres"

Reproduced the exact failure and the fix on PostgreSQL 16: an array column needs an explicit base type plus array: true, or synchronize throws.

7 min read
PostgreSQL

Fix npx prisma db push Hanging on Supabase (Port 6543)

Reproduced against Supavisor: the same schema waits until killed on port 6543 and syncs on 5432. The port, directUrl and prisma.config.ts fixes, version by version.

8 min read
PostgreSQL

Fix Postgres 5432 bind: address already in use in Docker

Tell the Docker messages apart, find what owns port 5432 on Linux, macOS or Windows, and pick between stopping it and moving the published port.

8 min read
PostgreSQL

Prisma deleteMany: Foreign key constraint failed (P2003)

Why profile.deleteMany() is blocked by Project_profile_email_fkey, which common tweaks leave the error in place, and how to prove the child rows are really gone.

9 min read
PostgreSQL

Prisma $queryRaw Fails With Variables Inside Single Quotes

Why interval and LIKE patterns break in Prisma raw SQL, the rewrites that work on Prisma 6 and 7, and how to prove the query now uses your value.

8 min read
PostgreSQL

Fix: Can't Migrate Schema Using Prisma With Supabase

The message comes from PgBouncer, and the same mistake now shows up as a silent hang: which port Prisma Migrate needs on Supabase, and how to keep both URLs in Prisma 6 and 7.

7 min read
PostgreSQL

Fix ECONNREFUSED 127.0.0.1:5432 in Docker Compose (Node)

Your Node app and Postgres both start, yet every query fails with connection refused. Read the address in the error, fix the host, and gate startup on pg_isready.

8 min read
PostgreSQL

Prisma Migrate P3014: permission denied to create database

Hit `P3014: permission denied to create database` when running Prisma Migrate on Heroku Postgres? Use prisma db push, a separate shadow database, or grant CREATEDB — and fix hangs with Supabase pooled connections.

7 min read
PostgreSQL

Prisma Migrate Dev Hangs? Fix the Supabase Pooler Stall

Reproduced on Supavisor: migrate dev waits at an early query on 6543 and migrates in a second on 5432. The fix for Prisma 6 and 7, and why the advisory lock is not the cause.

9 min read
PostgreSQL

Fix Deno 'UnsupportedCertVersion' TLS Error on Supabase

Deno Deploy throws 'UnsupportedCertVersion' TLS error when connecting to Supabase Postgres. Here's how to use --unsafely-ignore-certificate-errors and verify your connection stays secure.

7 min read
PostgreSQL

Prisma Can't Connect to PostgreSQL: Fix invalid port

Prisma error "invalid port number" often means your password contains characters like @ or # that break URL parsing. This guide shows how to percent-encode them and confirm the fix.

7 min read
PostgreSQL

Fix: drizzle-kit push — statement does not return data

drizzle-kit push failing with a driver-level TypeError on SQLite/libSQL/Turso setups. Why .run() and .get() aren't interchangeable, and the two safe ways around it.

7 min read
PostgreSQL

Prisma: Can't reach database server at database:5432 on M1

Check the address seen by the app container, preserve the PostgreSQL volume and distinguish a reachable database from a healthy container.

7 min read
PostgreSQL

Extract date (yyyy/mm/dd) from a timestamp in PostgreSQL

Confused by extracting date from a timestamp in PostgreSQL? Learn how to cast to ::date, use date_trunc, and verify column types for straightforward table insertion.

7 min read
PostgreSQL

Fix Missing Headers in PostgreSQL CSV Export (2026)

Stop getting CSV exports without column names. Master the HEADER option, avoid the 'delimiters' mistake, and use COPY vs \COPY the right way.

7 min read
PostgreSQL

PostgreSQL INSERT IF NOT EXISTS: ON CONFLICT and NOT EXISTS

Stop getting 'duplicate key value violates unique constraint' errors in PostgreSQL. Use INSERT ... ON CONFLICT DO NOTHING with RETURNING to atomically insert only when the row is missing.

7 min read
PostgreSQL

How to Get Enums in Prisma Client: Import, Query

Stuck trying to access Prisma enum values? This guide shows you exactly how to import, use, and validate generated enum types in your Node.js app.

7 min read
PostgreSQL

How to Exit psql: \q, exit, quit and Ctrl+D

The psql prompt is not a shell: exit and quit only work on PostgreSQL 11 and newer, and only when nothing is in the query buffer. \q works everywhere. Here is every way out, including the pager and half-typed statements.

5 min read
PostgreSQL

Fix PostgreSQL Server Won't Start on Mac OS X (2026)

A fresh Homebrew install of PostgreSQL on a Mac completes without errors, then psql answers connection refused because the server was never started. Which command starts it depends on

8 min read
PostgreSQL

Which version of PostgreSQL am I running? 3 ways to check

Need to know your PostgreSQL version for troubleshooting or feature compatibility? Here's how to check it using psql, a SQL query, or pg_config, plus how to interpret the output.

7 min read
PostgreSQL

FATAL: password authentication failed for user "postgres"

The error fires when PostgreSQL rejects the password the client sent — common when a role never got a password, when an old md5 hash meets a scram-sha-256 rule in pg_hba.conf, or when a Docker volume still holds an older password. Set the password with ALTER USER, then check the hash type.

6 min
PostgreSQL

psql command not found: install the client or fix PATH

The error fires when the shell cannot locate the psql binary — either PostgreSQL is not installed (only libpq-dev or a GUI client is), or it is installed but its bin directory is not on PATH. Fix it by installing the postgresql-client package on Linux, libpq via Homebrew on macOS, PostgreSQL itself (choco on Windows), or appending the bin directory to PATH.

6 min
PostgreSQL

How to Drop All Tables in PostgreSQL Safely (2026)

Dropping tables one by one is painful. Here is the one-command reset, the PostgreSQL 15 permission gotcha that breaks it, and the safe way to do it on Supabase.

9 min read
PostgreSQL

Switch Databases in psql: The \connect Command (2026)

MySQL uses USE. psql does not. You switch databases by opening a new connection with \c — and it fails if you are inside a transaction.

6 min read
PostgreSQL

How to Change a PostgreSQL User Password (Supabase)

`ALTER ROLE alice WITH PASSWORD 'newpass';` is the SQL. The psql `\password` prompt avoids logging the cleartext. In Supabase the `postgres` role password is reset from the Dashboard, not SQL. Here is each method, the scram-sha-256 default, and the three things that break after a password change.

10 min read
PostgreSQL

PostgreSQL SHOW TABLES / DESCRIBE TABLE (psql + Supabase)

Coming from MySQL you type `SHOW TABLES` or `DESCRIBE table` and PostgreSQL throws a syntax error — both are MySQL commands. The psql equivalents are `\dt` (list tables) and `\d table_name` (describe a table); the portable SQL equivalents are `information_schema.tables` and `information_schema.columns`. Here is exactly what to run in psql, the Supabase SQL editor, Drizzle, or any client, plus why your query returns zero rows.

9 min read
PostgreSQL

PostgreSQL DESCRIBE TABLE: The psql \d Equivalent

Coming from MySQL you type DESCRIBE table and psql throws a syntax error. The psql equivalent is \d table_name. For Supabase, Drizzle, or any SQL client without backslash commands, use the information_schema.columns view.

5 min
PostgreSQL

psql: FATAL: Peer authentication failed for user "postgres"

The error fires when PostgreSQL's peer auth check compares the OS username to the database role and they differ — common after sudo-ing into psql or in local dev. Fix it by matching users, or by switching the local auth method to scram-sha-256 with a real password.

6 min
PostgreSQL

Fix Postgres 'Could Not Serialize Access' (40001)

Postgres aborts one transaction with 40001 to prevent a serialization anomaly. The docs are explicit: apps using REPEATABLE READ or SERIALIZABLE must be prepared to retry. Here's the correct retry loop and how to reduce conflicts.

9 min read
PostgreSQL

Fix Foreign Key Constraint Violation in Supabase (23503)

23503 means a foreign key relationship is broken. Inserting a child before its parent? Insert the parent first. Can't delete a parent with children? Choose an ON DELETE action. The most common Supabase case is a profiles row referencing auth.users.

9 min read
PostgreSQL

Select the First Row per Group in Supabase Postgres

The "greatest-N-per-group" problem: one representative row per group. Postgres solves it with DISTINCT ON; supabase-js can't express that directly, so you wrap it in a view or an RPC function. Both confirmed by Supabase maintainers.

8 min read
PostgreSQL

Supabase Enums: ALTER TYPE ADD VALUE in Migrations

Step‑by‑step guide to adding a PostgreSQL enum type and column in Supabase, including verification and common pitfalls.

7 min read
PostgreSQL

Zero-Downtime Supabase Migrations: Expand/Contract (2026)

A production playbook for zero-downtime Supabase migrations: expand/contract, safe column renames, backfills, NOT VALID constraints, concurrent indexes, rollback planning, and CI gates.

34 min read
PostgreSQL

Database Design for Next.js + Supabase: Optimization Guide

Master PostgreSQL database design, indexing strategies, query optimization, and scaling patterns for high-performance Next.js and Supabase applications. Learn schema design, performance tuning, and production optimization.

30 min read
PostgreSQL

Supabase Connection Pooling: PgBouncer on Vercel Serverless

Serverless functions exhaust Postgres connections fast. Learn how to configure Supabase connection pooling with PgBouncer, choose the right pool mode, and avoid the connection limit errors that kill production apps on Vercel.

12 min read
PostgreSQL

Supabase Postgres Functions & Triggers: Developer Guide

Master Postgres functions and triggers in Supabase. Build automated workflows, complex business logic, and database-level validation with PL/pgSQL.

20 min read