Laravel Migration error SQLSTATE[25P02]: In failed sql transaction: 7 ERROR
Got this error when doing migrating.
SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block (Connection: pgsql, SQL: alter table "users" add constraint "users_email_unique" unique ("email"))
at vendor\laravel\framework\src\Illuminate\Database\Connection.php:824
820▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
821▕ );
822▕ }
823▕
➜ 824▕ throw new QueryException(
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕ }
1 vendor\laravel\framework\src\Illuminate\Database\Connection.php:570
PDOException::("SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block")
2 vendor\laravel\framework\src\Illuminate\Database\Connection.php:570
PDOStatement::execute()
Now this is the migration:
return new class extends Migration
{
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
};
In my local pgsql it is working. But with neon and v17 pgsql it is giving error.2 Replies
fair-rose•4w ago
Did the users table exist beforehand?
If you run it with a if (!Schema::hasTable('users')) does it work?
inland-turquoise•3w ago
Remove pooling from neon database.