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.

Prisma Website

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 Studio
  • pnpm db:generate - Generate the Prisma client
  • pnpm db:migrate - Migrate the database
  • pnpm db:migrate:dev - Migrate the database in dev mode
  • pnpm db:migrate:reset - Reset the database
  • pnpm db:migrate:deploy - Deploy the migrations
  • pnpm db:migrate:save - Save the migrations