You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/100-getting-started/01-quickstart-prismaPostgres.mdx
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,12 @@ In this Quickstart guide, you'll learn how to get started from scratch with Pris
17
17
- Schema migrations and queries (via [Prisma ORM](https://www.prisma.io/orm))
18
18
- Connection pooling and caching (via [Prisma Accelerate](https://www.prisma.io/accelerate))
19
19
20
+
:::note
21
+
22
+
If you want to use Prisma Postgres with another ORM or database library (like Drizzle ORM, TypeORM or Kysely), you can follow the instructions [here](/postgres/introduction/getting-started#connect-via-any-database-library--tool).
In the third step, you will be using the [TCP tunnel](/postgres/database/tcp-tunnel) to securely connect to your Prisma Postgres database during to run `pg_restore`.
21
+
In the third step, you will be using a [direct connection](/postgres/database/direct-connections) to securely connect to your Prisma Postgres database during to run `pg_restore`.
22
22
23
23
## Prerequisites
24
24
@@ -27,50 +27,6 @@ In the third step, you will be using the [TCP tunnel](/postgres/database/tcp-tun
27
27
- Node.js 18+ installed
28
28
- PostgreSQL CLI Tools (`pg_dump`, `pg_restore`) for creating and restoring backups
# During installation, select "Command Line Tools".
51
-
# Then verify with:
52
-
53
-
where pg_dump
54
-
where pg_restore
55
-
```
56
-
</TabItem>
57
-
58
-
<TabItemvalue="Linux">
59
-
```terminal
60
-
sudo apt-get update
61
-
sudo apt-get install postgresql-client-16
62
-
which pg_dump
63
-
which pg_restore
64
-
```
65
-
</TabItem>
66
-
67
-
</TabbedContent>
68
-
69
-
:::tip
70
-
If you installed PostgreSQL but still see a “command not found” error for pg_dump or pg_restore, ensure your installation directory is in your system’s PATH environment variable.
71
-
::: -->
72
-
73
-
74
30
## 1. Create a new Prisma Postgres database
75
31
76
32
Follow these steps to create a new Prisma Postgres database:
@@ -82,7 +38,7 @@ Follow these steps to create a new Prisma Postgres database:
82
38
1. In the **Region** dropdown, select the region that's closest to your current location, e.g. **US East (N. Virginia)**.
83
39
1. Click the **Create project** button.
84
40
85
-
Once your database was provisioned, find your Prisma Postgres connection URL in the **Set up database access** section and save it for later, you'll need it in step 3.
41
+
With your Prisma Postgres instance being created, you can move to the next step.
86
42
87
43
## 2. Export data from your existing database
88
44
@@ -118,18 +74,6 @@ Expand below for provider-specific instructions that help you determine the righ
In this section, you'll use a [direct connection](/postgres/database/direct-connections) in order to connect to your Prisma Postgres instance and import data via `pg_restore`.
You don't need to provide username and password credentials to this command because the TCP tunnel already authenticated you via the API key in your Prisma Postgres connection URL.
231
-
:::
232
-
233
148
You now successfully imported the data from your your existing PostgreSQL database into Prisma Postgres 🎉
234
149
235
150
To validate that the import worked, you can use [Prisma Studio](/postgres/database/tooling#viewing-and-editing-data-in-prisma-studio). Either open it in the [Platform Console](https://console.prisma.io) by clicking the **Studio** tab in the left-hand sidenav in your project or run this command to launch Prisma Studio locally:
Copy file name to clipboardExpand all lines: content/100-getting-started/03-prisma-postgres/115-import-from-existing-database-mysql.mdx
+14-59Lines changed: 14 additions & 59 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ This guide provides step-by-step instructions for importing data from an existin
15
15
You can accomplish this migration in four steps:
16
16
17
17
1. Create a new Prisma Postgres database.
18
-
1. Connect directly to a Prisma Postgres instance using the [`@prisma/ppg-tunnel` package](https://www.npmjs.com/package/@prisma/ppg-tunnel).
18
+
1. Connect directly to a Prisma Postgres instance using a [direct connection](/postgres/database/direct-connections).
19
19
1. Migrate your MySQL data to Prisma Postgres using [pgloader](https://pgloader.io/).
20
20
1. Configure your Prisma project for Prisma Postgres.
21
21
@@ -39,75 +39,30 @@ Follow these steps to create a new Prisma Postgres database:
39
39
1. In the **Region** dropdown, select the region that's closest to your current location, e.g. **US East (N. Virginia)**.
40
40
1. Click the **Create project** button.
41
41
42
-
Once your database was provisioned, find your Prisma Postgres connection URL in the **Set up database access** section and save it for later, you'll need it in the next step.
42
+
Once your database was provisioned, find your direct Prisma Postgres connection string:
43
+
44
+
1. Navigate to your active Prisma Postgres instance.
45
+
1. Click the **API Keys** tab in the project's sidenav.
46
+
1. Click the **Create API key** button.
47
+
1. In the popup, provide a **Name** for the API key and click **Create**.
48
+
1. Copy the connection string starting with `postgres://`, this is your direct connection string.
49
+
50
+
Save the connection string, you'll need it in the next step.
43
51
44
52
## 2. Connect directly to a Prisma Postgres instance
45
53
46
-
In this step, you'll use a secure [TCP tunnel](/postgres/database/tcp-tunnel) to connect to your Prisma Postgres instance.
54
+
In this step, you'll use a [direct connection](/postgres/database/direct-connections) to connect to your Prisma Postgres instance.
47
55
48
56
You'll need the Prisma Postgres connection URL from [step 1](/getting-started/prisma-postgres/import-from-existing-database-mysql#1-create-a-new-prisma-postgres-database):
If you already have a `.env` file in your current directory with `DATABASE_URL` set, the tunnel CLI will automatically pick it up, no need to manually export it. However, if you haven't set up a `.env` file, you'll need to set the `DATABASE_URL` environment variable explicitly.
54
-
55
-
To set the environment variable, open your terminal and set the `DATABASE_URL` environment variable to the value of your Prisma Postgres database URL (replace the `__API_KEY__` placeholder with the API key of your actual database connection URL):
You can [specify a different host and port](/postgres/database/tcp-tunnel#customizing-host-and-port) by providing your own host and port values using the `--port` and `--host` flags. Just be sure to use the same host and port values consistently throughout the guide.
77
-
78
-
:::
79
-
80
-
</cmd>
81
-
82
-
<cmdResult>
83
-
84
-
```code no-copy wrap
85
-
Prisma Postgres auth proxy listening on 127.0.0.1:5433 🚀
86
-
87
-
Your connection is authenticated using your Prisma Postgres API key.
88
-
...
89
-
90
-
==============================
91
-
hostname: 127.0.0.1
92
-
port: 5433
93
-
username: <anything>
94
-
password: <none>
95
-
==============================
96
-
```
97
-
98
-
</cmdResult>
99
-
100
-
</CodeWithResult>
101
-
102
-
:::note
103
-
104
-
*Keep your current terminal window or tab open* so that the tunnel process continues running and the connection remains open.
105
-
106
-
:::
107
62
108
63
## 3. Migrate your MySQL data to Prisma Postgres using pgloader
109
64
110
-
Now that you have an active connection to your Prisma Postgres instance, you'll use pgloader to export data from your MySQL database to Prisma Postgres.
65
+
Now that you have an active connection to your Prisma Postgres instance, you'll use [pgloader](https://pgloader.io/) to export data from your MySQL database to Prisma Postgres.
111
66
112
67
Open a separate terminal window and create a `config.load` file:
113
68
@@ -120,7 +75,7 @@ Open the `config.load` file in your preferred text editor and copy-paste the fol
120
75
```text file=config.load
121
76
LOAD DATABASE
122
77
FROM mysql://username:password@host:PORT/database_name
WITH quote identifiers, -- preserve table/column name case by quoting them
126
81
include drop,
@@ -137,7 +92,7 @@ Make sure to update the following details in the `config.load` file:
137
92
- Replace `username`, `password`, `host`, `PORT`, and `database_name` with the actual connection details for your MySQL database.
138
93
- Ensure that your connection string includes `useSSL=true` if SSL is required, for example: `mysql://username:password@host:PORT/database_name?useSSL=true`. Note that when using PlanetScale, appending `sslaccept=strict` will not work.
139
94
-`INTO` url (Postgres database URL):
140
-
- Update this with your TCP tunnel details if you’re using a custom `host` and `port` (in this example, it’s `127.0.0.1` and port `5433` for consistency).
95
+
- Update this with your direct connection string from above, replacing the `__USER__` and `__PASSWORD__` placeholders.
141
96
- Update the `database_name` in `ALTER SCHEMA 'database_name' RENAME TO 'public';` to exactly match the `database_name` in your MySQL connection string.
142
97
143
98
After saving the configuration file with your updated credentials, in the same terminal window, execute the following command:
0 commit comments