Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Externally managed tables are frequently used in combination with [multi-schema]
:::warning
Prisma ORM will not verify that the structure of the tables in the database and the structures of the Prisma models actually match.
On the one hand, it requires the developer to be thorough when updating the Prisma schema (the safest way to do it is by using `prisma db pull`).
On the other hand, this flexibility enables to only represent a part of the underlying table in the database (and e.g. not expose _all_ its columns).
On the other hand, this flexibility enables you to represent only part of the underlying table in the database (and e.g. not expose _all_ its columns).
:::

## Workflow
Expand Down Expand Up @@ -71,8 +71,8 @@ export default defineConfig({
})
```

- Analoguous to tables, you can also have externally managed _enums_.
- On PostgreSQL and SQL server you have to specify the fully qualified table/enum name including the schema name. For example: `public.products` or `auth.users`.
- Analogous to tables, you can also have externally managed _enums_.
- On PostgreSQL and SQL Server you have to specify the fully qualified table/enum name including the schema name. For example: `public.products` or `auth.users`.
- On MySQL and SQLite, you only have to specify the table name.

## Relationships
Expand Down Expand Up @@ -159,7 +159,7 @@ CREATE TABLE posts (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
title VARCHAR(200) NOT NULL,
content TEXT,
content TEXT
);
```

Expand Down
38 changes: 30 additions & 8 deletions content/200-orm/500-reference/325-prisma-config-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export declare type PrismaConfig = {
// Configuration for Prisma migrations.
migrations?: {
path: string;
seed: string;
initShadowDb: string;
};

// Configuration for the database view entities.
Expand Down Expand Up @@ -227,6 +229,34 @@ export default defineConfig({

Learn more about the [`externalTables` feature here](/orm/prisma-schema/data-model/externally-managed-tables).

### `migrations.path`

The path to the directory where Prisma should store migration files, and look for them.

| Property | Type | Required | Default |
| ----------------- | -------- | -------- | ------- |
| `migrations.path` | `string` | No | none |

### `migrations.seed`

This option allows you to define a script that Prisma runs to seed your database after running migrations or using the npx prisma db seed command. The string should be a command that can be executed in your terminal, such as with `node`, `ts-node`, or `tsx`.

| Property | Type | Required | Default |
| ----------------- | -------- | -------- | ------- |
| `migrations.seed` | `string` | No | none |

**Example:**

```ts
import { defineConfig } from "prisma/config";

export default defineConfig({
migrations: {
seed: `tsx db/seed.ts`,
},
});
```

### `migrations.initShadowDb`

This option allows you to define SQL statements that Prisma runs on the **shadow database** before creating migrations. It is useful when working with [external managed tables](/orm/prisma-schema/data-model/externally-managed-tables), as Prisma needs to know about the structure of these tables to correctly generate migrations.
Expand Down Expand Up @@ -257,14 +287,6 @@ export default defineConfig({

Learn more about the [`externalTables` feature here](/orm/prisma-schema/data-model/externally-managed-tables).

### `migrations.path`

The path to the directory where Prisma should store migration files, and look for them.

| Property | Type | Required | Default |
| ----------------- | -------- | -------- | ------- |
| `migrations.path` | `string` | No | none |

### `views.path`

The path to the directory where Prisma should look for the SQL view definitions.
Expand Down
Loading