-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
docs: add supabase guide #297
Conversation
|
## Requirements | ||
|
||
- [docker](https://docs.docker.com/engine/install/) | ||
- time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
This looks amazing! Great work 👍🏼. One requested tweak: could you specify a separate schema other than |
Sure thing. Will change that when I get a chance to finish up. Just FYI, changing the graphile-worker schema is also possible, should the need ever arise. |
@nicktrn would it be possible to get this merged in before 3pm GMT today? We're announcing something at 4pm today in a blog post and would love to be able to link to it 👍 |
@ericallam Not a problem, ☕ solves (almost) anything |
@ericallam I have added support for connection pools. Tests are passing. Will finish the writeup now. If you could have a look at this immediately, that would save time. Worst case, will have to publish without the bonus section on connection pools. |
Oh shoot I didn't realize this had changes to the webapp to get it to work. Unfortunately, we probably won't be able to get it in under the deadline as I don't have time to pull it down and test. So I think I will link to this PR from the blog post instead. Sorry again and thanks for this! Will hopefully be able to get it merged tomorrow 👍 |
No worries, would you like me to take out the last section for now and revert the webapp changes? That way you can publish the main part of the guide without any trouble and link to it directly. |
@ericallam linked PR without app changes. Hope this helps! |
1b8edff
to
af6e575
Compare
Just finished this up. Quick summary of changes:
Small caveat: Prisma requires an update for Studio to play nicely with pooling. But I'm sure you'll be upgrading soon (hint hint 😉 ) edit: DON'T review this yet! Just ran the e2e tests again and getting timeouts with pooling enabled. Hope it's just a latency issue as the DB isn't local. Will ping you when it's ready. |
@ericallam this is ready for review now. End-result is that nothing changes unless The tests are passing fine manually with and without pooling. Managed to get it working via playwright, but quite flaky. There are issues with the tests in general. Boils down to responses not being awaited before navigating, timeouts not considering latency (dev/prod, local/remote db), and setup/teardown being a mess. Ideally this should be done with fixtures or dependencies instead. Will have a proper look when I get a chance and sort things out. Re the |
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=public | ||
# This sets the URL used for direct connections to the database and should only be needed in limited circumstances | ||
# See: https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#fields:~:text=the%20shadow%20database.-,directUrl,-No | ||
DIRECT_URL=${DATABASE_URL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't just be empty as we have to use an env var in schema.prisma
@@ -122,7 +122,6 @@ jobs: | |||
# Setup environment variables | |||
cp ./.env.example ./.env | |||
cp ./examples/nextjs-test/.env.example ./examples/nextjs-test/.env.local | |||
cp ./packages/database/.env.example ./packages/database/.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed anymore due to symlink
cp .env.example .env && cp packages/database/.env.example packages/database/.env | ||
cp .env.example .env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed anymore due to symlink
@@ -178,7 +178,6 @@ To run the end-to-end tests, follow the steps below: | |||
```sh | |||
cp ./.env.example ./.env | |||
cp ./examples/nextjs-test/.env.example ./examples/nextjs-test/.env.local | |||
cp ./packages/database/.env.example ./packages/database/.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed anymore due to symlink
@@ -94,6 +94,7 @@ function getWorkerQueue() { | |||
connectionString: env.DATABASE_URL, | |||
concurrency: 5, | |||
pollInterval: 1000, | |||
noPreparedStatements: env.DATABASE_URL !== env.DIRECT_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way around this with pooling
I'm happy with the |
Sure. The Prisma CLI requires a direct connection for some commands, i.e. not via an external pool. Unless you hardcode this in the schema file, the only way is to use an env var. Sadly, once we do this, that env var can't be unset / empty as Prisma doesn't allow us to set defaults and will complain otherwise: # unset
error: Environment variable not found: DIRECT_URL.
--> schema.prisma:4
# empty
error: Error validating datasource `db`: You must provide a nonempty direct URL. The environment variable `DIRECT_URL` resolved to an empty string.
--> schema.prisma:4 |
That makes sense. Let me know when this is ready for review 👍 |
Should be ready now! |
Okay, I just pulled this down and took a look at this and it all looks great. There is one issue though, our self-hosting guides will need to be updated:
And our docker repo: https://github.com/triggerdotdev/docker I'll update the docker repo but do you think you could update the self-hosting guides? |
Yes, I did think that as well. I'll have a look and see what needs changing! |
Fixed the Fly.io guide, got an error following the instructions however. Creating the db failed as the default instance couldn't run Postgres:
The next tier up was shared-cpu-2x - CPU Kind: Shared, vCPUs: 2, Memory: 4GB which worked. Why the jump in specs I wonder.. The Render guide is a different matter. Don't know what to do there. It doesn't seem to have a DB attached and I couldn't set up an instance following those steps. My guess is it could all be configured in Made a quick change to the docker repo as well and small README change to fly.io to follow shortly. |
This looks good, I'm going to merge this and the other PRs now and create a new |
Excellent, let me know if you run into any issues due to my changes. |
Tracking this here in case Postgres Extensions are ever added to the Prisma schema: |
Adds a Supabase guide to the self-hosting section.
WIP for now. Will be adding connection pooling via PgBouncer to the guide.
This has first class support in both Supabase and Prisma, and should benefit not just self-hosters but the project in general. Can be easily self-hosted, and reduces the need for Data Proxy.
There is also a trimmed down compose file in the guide that may benefit from being included in triggerdotdev/docker
Fixes #279
/claim #279