Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma docs updates #353

Merged
merged 5 commits into from
Jul 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8
- name: Install Node.js dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prettier-fixes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# This makes git push to work and other workflows to run
token: ${{ secrets.GIT_TOKEN }}

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8

Expand Down
9 changes: 8 additions & 1 deletion 020-Connect/010-Postgres/001-direct-access.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ PostgreSQL 15.4 on aarch64-unknown-linux-gnu, compiled by aarch64-unknown-linux-

## Extensions

Extensions are only available in [dedicated cluster](/docs/dedicated-cluster#Extensions) plans. The default shared cluster setup ships with [plpgsql](https://www.postgresql.org/docs/current/plpgsql.html) only.
The default shared cluster setup ships with

- [pgcrypto](https://www.postgresql.org/docs/current/pgcrypto.html)
- [pgvector](https://github.com/pgvector/pgvector)
- [plpgsql](https://www.postgresql.org/docs/current/plpgsql.html)
- [uuid-ossp](https://www.postgresql.org/docs/current/uuid-ossp.html)

More extensions are available in [dedicated cluster](/docs/dedicated-cluster#Extensions) plans.

## Export

Expand Down
11 changes: 7 additions & 4 deletions 020-Connect/020-JavaScript/020-prisma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ To use Xata with Prisma define a postgresql datasource in the `schema.prisma` fi
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
```

Expand All @@ -55,6 +56,8 @@ To introspect the database, you can use the following command:
prisma db pull
```

Introspection is necessary after _Adapting_ an existing table in the UI. This action adds columns `xata_id`,`xata_createdat`,`xata_updatedat` to the table. `prisma db pull` updates the Prisma schema to include these.

To generate the client, you can use the following command:

```sh
Expand All @@ -75,12 +78,12 @@ const result = await prisma.users.findMany({
});
```

## Shadow Database
## Shadow Database for Migrations

Migrations with Prisma require a [shadow database](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database).
Migrations with Prisma require a [Shadow Database](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database), which is an extra database that stores migration information and state.

For this purpose, create an additional database in Xata and configure its Postgres endpoint as `shadowDatabaseUrl` in the datasource, as suggested by the relevant [Prisma documentation](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database#cloud-hosted-shadow-databases-must-be-created-manually).
Create an additional database in Xata (we recommend naming it databasename-migrations), configure this database's [Postgres connection string](/docs/postgres#connection-string) as the `shadowDatabaseUrl` in the Prisma datasource and store the connection string in your `.env` file as `SHADOW_DATABASE_URL`. Refer to Prisma's [documentation](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database#cloud-hosted-shadow-databases-must-be-created-manually) for more details.
kostasb marked this conversation as resolved.
Show resolved Hide resolved

## Limitations

- Xata [File attachments](/docs/sdk/file-attachments) columns are read-only and only shows file metadata. You will need to use the [SDK](/docs/sdk/typescript/overview) to upload and download files.
- Xata [File attachments](/docs/sdk/file-attachments) columns are read-only and only show file metadata. You will need to use the [SDK](/docs/sdk/typescript/overview) to upload and download files.
Loading