Deploying the Database

By now, this should be a familiar process. We'll use the same shuttle command we used to deploy the backend to deploy the database.

cargo shuttle deploy

As you've seen, we don't need to do anything special to deploy the database. Shuttle will detect that we have a database dependency in our code and will provision it for us. Neat, isn't it?

Infrastructure From Code

While the deployment takes place, you can take a look at this blog post to learn more about the concept of Infrastructure From Code.

Once the deployment is complete, you can check the database connection string in the terminal.

Database connection string

Don't worry if you missed it. You can always check the database connection string in the terminal by running the following command.

cargo shuttle resource list

You can also go to the Shuttle Console and check the database connection string there.

Console Resources

Testing the new endpoint

curl -i

You should get a response similar to the following.

HTTP/1.1 200 OK
content-length: 115
content-type: text/plain; charset=utf-8
date: Sat, 01 Jul 2023 16:27:07 GMT

PostgreSQL 14.8 (Debian 14.8-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit