Database Integration
TheDevSpace boilerplate is built with Prisma ORM, which allows you to connect and interact with different database with a single schema.
By default, TheDevSpace is configured to connect to a local SQLite database. It is good for testing purposes, but I recommend using a production ready database instead.
Create a new database
Postgres is one of the best choices for relational databases. It is open source, popular, and stable.
There are many places you can host a Postgres database, such as Supabase, DigitalOcean, or AWS.
If you plan to host your SaaS on Vercel, you can also create a Postgres database directly from there.
Connect to the database
Regardless of the platform you choose, you should receive a database connection URL that looks like this:
postgres://default:XXXXXXXXX@ep-xxx-xxxx-xxx-xx-xxxx-xxx.us-east-1.aws.neon.tech/xxxxxdb?sslmode=require
Copy and paste it into the .env
file as the value for the variable DATABASE_URL
.
And then go to prisma/schema.prisma
, and update the datasource
section:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Notice that the provider has been updated from sqlite
into postgresql
.
Run database migration
And finally, apply the database migration by running the following command, and you're good to go.
npx prisma migrate dev --name init