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

> For the complete Prisma documentation index, see [llms.txt](/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Native database types

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

Prisma Migrate translates the model defined in your [Prisma schema](/guides/prisma-schema-v7-overview) into features in your database.

<img src="https://www.prisma.io/img/orm/prisma-migrate/understanding-prisma-migrate/migrate-mapping.png" alt="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](/guides/prisma-schema-v7-data-model-models) 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:

- [Database features matrix](/guides/reference-6-v7-reference-database-features) for a list of database features and what they map to in the Prisma schema.
- [Prisma schema reference](/guides/reference-6-v7-reference-prisma-schema-reference) for a list of all Prisma schema features, including field types, attributes, and functions.

Prisma Migrate also supports mapping each field to a [specific native type](#mapping-fields-to-a-specific-native-type), and there are ways to [include features without a Prisma schema equivalent in your database](#handling-unsupported-database-features).

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

## Mapping fields to a specific native type

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](/guides/prisma-schema-v7-data-model-models#native-types-mapping) 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 title="schema.prisma" highlight=8,14;normal
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 title="migration.sql" highlight=4,10;normal
  -- 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;
```

### Mappings by Prisma ORM type

For type mappings organized by Prisma ORM type, refer to the [Prisma schema reference](/guides/reference-6-v7-reference-prisma-schema-reference#model-field-scalar-types) documentation.

### Mappings by database provider

For type mappings organized by database provider, see:

- [PostgreSQL mappings](/guides/core-concepts-v7-supported-databases-postgresql#prisma-to-postgresql)
- [MySQL mappings](/guides/core-concepts-v7-supported-databases-mysql#type-mapping-between-mysql-and-prisma-schema)
- [Microsoft SQL Server mappings](/guides/core-concepts-v7-supported-databases-sql-server#type-mappings)
- [SQLite mappings](/guides/core-concepts-v7-supported-databases-sqlite#type-mappings)

## Handling unsupported database features

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 trigger in PSL. However, there are ways to add unsupported features to your database with Prisma Migrate:

- [Handle unsupported field types](/guides/prisma-schema-v7-data-model-unsupported-database-features#unsupported-field-types) (like `circle`)
- [Handle unsupported features](/guides/prisma-schema-v7-data-model-unsupported-database-features#unsupported-database-features), like stored procedures
- [How to use native database functions](/guides/prisma-schema-v7-data-model-unsupported-database-features#native-database-functions)

## Related pages

- [`Baselining a database`](/guides/prisma-migrate-v7-workflows-baselining): How to initialize a migration history for an existing database that contains important data.
- [`Customizing migrations`](/guides/prisma-migrate-v7-workflows-customizing-migrations): How to edit a migration file before applying it to avoid data loss in production.
- [`Development and production`](/guides/prisma-migrate-v7-workflows-development-and-production): How to use Prisma Migrate commands in development and production environments
- [`Generating down migrations`](/guides/prisma-migrate-v7-workflows-generating-down-migrations): How to generate a down migration SQL file that reverses a given migration file
- [`Native database functions`](/guides/prisma-migrate-v7-workflows-native-database-functions): How to enable PostgreSQL native database functions for projects that use Prisma Migrate.

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
