Unable to create or change a table without a primary key - Laravel DigitalOcean Managed Database

Michal Deimert

I've just deployed my app to DigitalOcean using (Managed Database) and I'm getting the following error when calling php artisan migrate

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 `sessions` (`id` varchar(255) not null, `user_id` bigint unsigned null, `ip_address` varchar(45) null, `user_agent` text null, `payload` text not null, `last_activity` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

It appears that Laravel Migrations doesn't work when mysql var sql_require_primary_key is set to true.

Do you have any solutions for that?

Ersoy

According to the MySQL documentation purpose of this system variable is

to avoid replication performance issues: "Enabling this variable helps avoid performance problems in row-based replication that can occur when tables have no primary key."

IMHO, there are two possible options to consider for your problem;

  • Add primary key to this and every table in your migration, including temporary tables. This one is better and i think more convenient way to do it since there is no drawback to have primary key for each table.

Whether statements that create new tables or alter the structure of existing tables enforce the requirement that tables have a primary key.

  • Change your provider because according to here "We support only MySQL v8."

Also here is the bug report

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to add a primary key to a mysql table without a primary key

How to define a table without primary key with SQLAlchemy?

Generate Primary key without using Database

How can i change timezone in the Managed MYSQL Database in DigitalOcean?

Entity Framework: table without primary key

Change primary key in PostgreSQL table

Import CSV without primary key to existing table

Laravel change default primary key of users table

Deleting records from a table without primary key

Is it possible to create an identity column in Oracle without it being a primary key, and how does it relate to H2 Database?

How to change primary key of Room database?

Create a table with a varchar as primary key

create a foreign key on a primary key of another table

MS Access query table without primary key

Create an UPDATE statement without primary key

Table without a primary key

Unable to create database table in Laravel 4.2

create primary key on existing table without primary key in SQL Server

Unable to create a table in database

Unable to drop primary key in mysql database

Delete from table without primary key in Sequel

Database Create table Primary key not found

Creating a SQL database without defining primary key

How to create table without primary key in Entity Framework Core?

It's possible, create a table without primary key in TypeOrm?

Creating a table in database defining a column as primary key

How can I change current value for identity type primary key column in table in PostgreSQL database?

Is it possible to create a table in the Room without a primary key?

If I create a table without a primary key then add a primary key, is the primary key a clustered index?