Created
October 16, 2024 15:39
-
-
Save arcanoix/6a012afded621f1780d54c124ce73621 to your computer and use it in GitHub Desktop.
Revisions
-
arcanoix created this gist
Oct 16, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ Digital Ocean has an API that you can use to configure the settings of your DB, which I would highly recommend over other solutions. You can do the following: Create an API token if you don't have one already: https://cloud.digitalocean.com/account/api/tokens Find the ID of your database cluster by querying the List all database clusters endpoint: curl -X GET \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/databases" Once you've found the ID of your database cluster, you can make a patch request to the update database config endpoint: curl -X PATCH \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"config": {"sql_require_primary_key": true}}' \ "https://api.digitalocean.com/v2/databases/$DATABASE_CLUSTER_ID/config" Now your database cluster will be configured, permanently, without any code changes.