forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:redwoodjs/redwood into mohsen--ts…
…-refs
- Loading branch information
Showing
147 changed files
with
3,827 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ packages/api/importAll.macro.js | |
lerna-debug.log | ||
yarn-error.log | ||
**/*.tsbuildinfo | ||
tasks/.verdaccio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Connection Pooling | ||
|
||
Production Redwood apps should enable connection pooling in order to properly scale with your Serverless functions. | ||
|
||
## Heroku | ||
For Postgres, see [Postgres Connection Pooling](https://devcenter.heroku.com/articles/postgres-connection-pooling). | ||
|
||
Heroku does not officially support MySQL. | ||
|
||
|
||
## Digital Ocean | ||
For Postgres, see [How to Manage Connection Pools](https://www.digitalocean.com/docs/databases/postgresql/how-to/manage-connection-pools) | ||
|
||
Connection Pooling for MySQL is not yet supported. | ||
|
||
## AWS | ||
Use [Amazon RDS Proxy] https://aws.amazon.com/rds/proxy for MySQL or RDS PostgreSQL. | ||
|
||
|
||
## Why Connection Pooling? | ||
|
||
Relational databases have a maximum number of concurrent client connections. | ||
|
||
* Postgres allows 100 by default | ||
* MySQL allows 151 by default | ||
|
||
In a traditional server environment, you would need a large amount of traffic (and therefore web servers) to exhaust these connections, since each web server instance typically leverages a single connection. | ||
|
||
In a Serverless environment, each function connects directly to the database, which can exhaust limits quickly. To prevent connection errors, you should add a connection pooling service in front of your database. Think of it as a load balancer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Local Postgres Setup | ||
|
||
RedwoodJS uses a SQLite database by default. While SQLite makes local development easy, you're | ||
likely going to want to run the same database setup you use on production. Here's how to set up | ||
Postgres. | ||
|
||
## Install Postgres | ||
|
||
Ensure you have Postgres installed and running on your machine. If you're on a Mac, we recommend | ||
Homebrew: | ||
|
||
```bash | ||
brew install postgres | ||
``` | ||
|
||
Follow the instructions provided. If you're using another platform, See | ||
[postgresql.org/download](https://www.postgresql.org/download/). | ||
|
||
## Update the Prisma Schema | ||
|
||
Tell Prisma to use a Postgres database instead of SQLite by updating the `provider` attribute in your | ||
`schema.prisma` file: | ||
|
||
```prisma | ||
// prisma/schema.prisma | ||
datasource DS { | ||
provider = "postgres" | ||
url = env("DATABASE_URL") | ||
} | ||
``` | ||
|
||
Add a `DATABASE_URL` to your `.env` file with the URL of the database you'd like to use locally. The | ||
following example uses `redwoodblog_dev` for the database. It also has `postgres` setup as a | ||
superuser for ease of use. | ||
|
||
```env | ||
DATABASE_URL="postgresql://postgres@localhost/redwoodblog_dev?connection_limit=1" | ||
``` | ||
|
||
Note the `connection_limit` parameter. This is [recommended by Prisma](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/deployment#recommended-connection-limit) when working with | ||
relational databases in a Serverless context. You should also append this parameter to your production | ||
`DATABASE_URL` when configuring your deployments. | ||
|
||
If you've already created migrations using SQLite, you just need to run migrations again: | ||
|
||
```bash | ||
yarn rw db up | ||
``` | ||
|
||
If you haven't created migrations yet, use `save`: | ||
|
||
```bash | ||
yarn rw db save | ||
``` | ||
|
||
Both commands will create and migrate the Postres database you specified in your `.env`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"command": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/*.test.[jt]s?(x)'], | ||
testPathIgnorePatterns: ['fixtures'], | ||
} |
Oops, something went wrong.