Database
AiStarterKit uses PostgreSQL by default to store user accounts and application data.
Setting up your database takes few steps:
- A database connection string
- Applying schema to the database
We are using the pg package, so any PostgreSQL database instance should work fine.
Database Connection String
Your database provider will give you a connection string that looks something like this:
postgres://[username]:[password]@[hostname]:5432/[database_name]
Now in your .env
file add the connection string for the variable named DATABASE_URL
.env
DATABASE_URL="postgres://[username]:[password]@[hostname]:5432/[database_name]"
Applying Schema To Database
Now let’s set up your database schema using Drizzle ORM
npm run db:generate # Generate the migrations
npm run db:migrate # Apply migrations to the database
Alternatively, you can use the following command to directly apply changes to the database.
npm run db:push