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

From March 2022, you can now configure your MYSQL and other database by making a request to digital ocean APIs.
Here’s the reference: https://docs.digitalocean.com/products/databases/mysql/#4-march-2022

STEPS TO FIX THE ISSUE:

Step – 1: Create AUTH token to access digital ocean APIs. https://cloud.digitalocean.com/account/api/tokens

STEP – 2: Get the database cluster id by hitting the GET request to the below URL with bearer token that you have just generated above.

URL: https://api.digitalocean.com/v2/databases

Step – 3: Hit the below URL with PATCH request along with the bearer token and payload.

URL: https://api.digitalocean.com/v2/databases/{YOUR_DATABASE_CLUSER_ID}/config

payload: {"config": { "sql_require_primary_key": false }}

That’s all. It worked flawlessly.

For more information, please refer to API DOCS:
https://docs.digitalocean.com/products/databases/mysql/#latest-updates

Leave a Comment

tech