Database
For database access, SveltePak uses Prisma
ORM.
Prisma supports a variety of databases, including PostgreSQL, MySQL, SQLite, and SQL Server.
Prisma is a modern database toolkit that makes it easy to work with databases in your application. It replaces traditional ORMs and makes database access easy with an auto-generated query builder for TypeScript & Node.js.
Drizzle ORM
is also going to be supported in the future.
Update your schema
To update your database schema, you can simply edit the /db/schema.prisma
.
You can find more information about the Prisma schema file here.
model User {
id String @id @default(cuid())
name String
email String @unique
emailVerifiedAt DateTime? @map("email_verified_at")
role Role @default(USER)
avatar String?
...
}
Generate the Prisma client
After updating your schema, you can run the following command to generate the Prisma client:
pnpm db:generate
Migrate your database
After generating the Prisma client, you can run the following command to migrate your database:
pnpm db:migrate
Prisma Commands
pnpm db:studio
- Open the Prisma Studiopnpm db:generate
- Generate the Prisma clientpnpm db:migrate
- Migrate the databasepnpm db:migrate:dev
- Migrate the database in dev modepnpm db:migrate:reset
- Reset the databasepnpm db:migrate:deploy
- Deploy the migrationspnpm db:migrate:save
- Save the migrations