can I create databases with Prisma?
# orm-help
a
can I create databases with Prisma?
n
Hey Ador 👋 a database is automatically created upon your first migration when you provide a valid connection string to a DB server 🙂
a
Sup @nikolasburk, I didn't quite get what you meant there, do you mind explaining a bit further?
n
For example, when you declare a data source in the Prisma schema like this:
Copy code
datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}
And e.g. run
npx prisma migrate dev
for the first time, Prisma will create the database file named
./dev.db
for you 🙂 The same with Postgres and MySQL, say you declare your data source like this for Postgres:
Copy code
datasource db {
  provider = "postgresql"
  url      = "<postgresql://USER:PASSWORD@HOST:5432/mydb>"
}
And run
npx prisma migrate dev
for the first time, Prisma will create a database called
mydb
on the given Postgres server for you!
a
@nikolasburk I see, is there any way I can programmatically create a database or do I have to run the command?