Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

elliotk's avatar

Password Reset Primary Key

Hello,

I am exploring Managed Database from Digital Ocean.

On migration I am getting the following issue..

Migrating: 2014_10_12_100000_create_password_resets_table

Illuminate\Database\QueryException

SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. (SQL: create table `password_resets` (`email` varchar(255) not null, `token` varchar(255) not null, `created_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Any advice on a solution for this?

0 likes
2 replies
Snapey's avatar

Add this one line to the up method of the migration

\Illuminate\Support\Facades\DB::statement('SET SESSION sql_require_primary_key=0');

It turns off the requirement for a primary key for this one migration

2 likes

Please or to participate in this conversation.