[Rails + Postgres] How can I reset my database, as well as seed it?

This is not being used yet, so I know the risks or resetting, but I can’t seem to figure out how to run db:reset. Is the only solution upgrading to a paid plan to access the shell?

Thank you in advance!

Hi Jeff,
On the free plan you’d need to use jobs to trigger the reset via our API:

curl --request POST 'https://api.render.com/v1/services/<service-ID>/jobs' \
    --header 'Authorization: Bearer API_TOKEN' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "startCommand": "rake db:reset"
    }'

John B

Thanks John! If I upgrade to paid, then can I just run ssh commands (like heroku) to access a lot more things?

Correct, paid plans have shell tab access and also you can use ssh to connect to the instance,

Regards,

1 Like

Where do I find the ID above? I created an API key, but I can’t seem to find that.

If you go to your dashboard > select the service > Settings, you can see the ID there a few times. Deploy Hook has it in the url such as https://api.render.com/deploy/{service-ID}?key=....

I do think it should simply be shown at the top with the other details.

Yep, the serviceID is always in the URL when looking at a service in thedashboard, it would be prefixed srv-

John B

I’m having trouble with the serviceID:
For a PostgreSQL database the url in my dashboard is:

http://dashboard.render.com/d/{{some-id}

Unfortunately some-id does not work as the serviceID in the curl command, it returns:

{"message":"not found: service: {{some-id}}"}

Some more information:
-some-id starts with dpg-
-in general other API calls like getting the list of services according to List services works for me, so the culprit seems to be the serviceID. Though in the list of services the PostgreSQL database is not listed…

Regards
Daniel

This is unrelated to the original question here. Please start a new topic.

Daniel,

Please refer to Jobs | Render · Cloud Hosting for Developers - jobs can only be created against a webservice, background worker or cronjob - you cannot create one against a database,

Regards,

Hello John,
thanks for your response!
Though I don’t think my question is unrelated to the original question, as the serviceID is needed in order to successfully execute the curl command in the answer to run db:reset and the identifier in the URL does not seem to work out.

I was not trying to create a job, just trying to reset the database with db:reset as asked in the original question.
Regards
Daniel

You’re right - I thought I’d deleted my original reply as I re-read your question and then provided the link to the docs.

No worries, for now I just went with deleting the db and instantiating a new one