current transaction is aborted, commands ignored until end of transaction block

Laravel app, just moved from MySQL to PostgreSQL. The full message as Laravel shows it:

SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block

Why it happens

This is a symptom. An earlier statement in the same transaction failed; MySQL would carry on, but Postgres refuses every statement until rollback. Code that catches an exception and keeps using the same transaction hits this.

Fix

-- find the FIRST error in the log, fix that one. -- if you must try-and-continue inside a transaction, wrap the risky step -- in a savepoint (nested DB::transaction() does this in Laravel).

Tested on Postgres 17: after a failing statement, the next one in the block returns 25P02.

More fixes like this one, as tested scripts: Laravel Postgres Error Fix Pack ($19).

Several errors at once? Paste your log into the error matcher. Raw SQL with MySQL syntax: the free SQL translator. Not migrated yet: the free schema risk check finds this kind of problem before the switch. Planning the whole move: Migration Kit ($49, $34.30 with LAUNCH30 until Nov 5).

Other errors after MySQL to Postgres

Published with deed.page