Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Native database types (Prisma ORM v6) (/docs/orm/v6/prisma-migrate/workflows/native-database-types)

For the complete Prisma documentation index, see llms.txt. A markdown version of any docs page is available by appending .md to its URL.

Native database types

Location: ORM > v6 > Prisma Migrate > Workflows > Native database types

Prisma Migrate translates the model defined in your Prisma schema into features in your database.

A diagram that shows a Prisma schema on the left (labeled: Prisma schema, models) and a database on the right (labeled: Database, tables). Two parallel arrows connect the schema and the database, showing how '@unique' maps to 'UNIQUE' and '@id' maps to 'PRIMARY KEY'.

Every¹ feature in your data model maps to a corresponding feature in the underlying database. *If you can define a feature in the Prisma schema, it is supported by Prisma Migrate.*

For a complete list of Prisma schema features, refer to:

Prisma Migrate also supports mapping each field to a specific native type, and there are ways to include features without a Prisma schema equivalent in your database.

[!NOTE] Comments and Prisma ORM-level functions (uuid() and cuid()) do not map to database features.

Each Prisma ORM type maps to a default underlying database type - for example, the PostgreSQL connector maps String to text by default. Native database type attributes determines which specific native type should be created in the database.

[!NOTE] Some Prisma ORM types only map to a single native type.

In the following example, the name and title fields have a @db.VarChar(X) type attribute:

prisma
datasource db {
  provider = "postgresql"
}

model User {
  id    Int    @id @default(autoincrement())
  name  String @db.VarChar(200)
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String  @db.VarChar(150)
  published Boolean @default(true)
  authorId  Int
  author    User    @relation(fields: [authorId], references: [id])
}

Prisma Migrate uses the specified types when it creates a migration:

SQL
  -- CreateTable
CREATE TABLE "User" (
    "id" SERIAL,
    "name" VARCHAR(200) NOT NULL,
    PRIMARY KEY ("id")
);
  -- CreateTable
CREATE TABLE "Post" (
    "id" SERIAL,
    "title" VARCHAR(150) NOT NULL,
    "published" BOOLEAN NOT NULL DEFAULT true,
    "authorId" INTEGER NOT NULL,
    PRIMARY KEY ("id")
);

  -- AddForeignKey
ALTER TABLE "Post" ADD FOREIGN KEY("authorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

For type mappings organized by Prisma ORM type, refer to the Prisma schema reference documentation.

For type mappings organized by database provider, see:

Prisma Migrate cannot automatically create database features that have no equivalent in Prisma Schema Language (PSL). For example, there is currently no way to define a stored procedure or a partial index in PSL. However, there are ways to add unsupported features to your database with Prisma Migrate:

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu