Skip to content

Instantly share code, notes, and snippets.

@arcanoix
Created October 16, 2024 15:39
Show Gist options
  • Save arcanoix/6a012afded621f1780d54c124ce73621 to your computer and use it in GitHub Desktop.
Save arcanoix/6a012afded621f1780d54c124ce73621 to your computer and use it in GitHub Desktop.

Revisions

  1. arcanoix created this gist Oct 16, 2024.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original 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.