docs: improve troubleshooting (#1739)

* docs: improve troubleshooting

* fixes
This commit is contained in:
Shahed Nasser
2022-06-27 16:57:24 +03:00
committed by GitHub
parent 6566bc1cf6
commit 1cc4f9ac2d
6 changed files with 78 additions and 46 deletions
@@ -1,45 +1,59 @@
# Error 409 in checkout
To provide the most frictionless onboarding and quick start, we default to SQLite as database. SQLite runs on all PCs, which is why it allows you to get quickly started without installing Postgres. Though, it comes at the expense of important features, that are needed in a production environment.
To provide the most frictionless onboarding and quickstart, Medusa uses SQLite as the server's database by default. SQLite runs on all machines and operating systems. So, it allows you to get quickly started without installing PostgreSQL.
Therefore, you might experience the following error when going through a checkout flow in our starters:
However, this comes at the expense of important features that are needed in a production environment.
```
Therefore, you might experience the following error when going through a checkout flow in one of Medusa's starters while using SQLite:
```bash
Error: Transaction already started for the given connection, commit current transaction before starting a new one.
```
This error occurs because SQLite does not allow for multiple write transactions at the same time. To resolve it, you need to use Postgres instead.
This error occurs because SQLite does not allow for multiple write transactions at the same time. To resolve it, you need to use PostgreSQL instead.
First install and start Postgres on your local machine. You can either [download it directly from their website](https://www.postgresql.org/download/) or use Homebrew:
You can learn how to install PostgreSQL on your machine in the [Set Up your Development Environment documentation](../tutorial/0-set-up-your-development-environment.mdx#postgresql).
```bash
brew install postgresql
brew services start postgresql
createdb
```
Then in your `medusa-config.js`, you should change the project config to use Postgres as database type:
Then in your `medusa-config.js`, you should change the project configuration to use Postgres as the database type:
```jsx
module.exports = {
projectConfig: {
redis_url: REDIS_URL,
// The following two lines will enable Postgres
//...
database_url: DATABASE_URL,
database_type: "postgres",
store_cors: STORE_CORS,
admin_cors: ADMIN_CORS,
},
plugins,
}
```
Where `DATABASE_URL` is the connection string to your PostgreSQL database. You can check out how to format it in [PostgreSQLs documentation](https://www.postgresql.org/docs/current/libpq-connect.html).
Make sure to also remove the following lines that are used to configure an SQLite database:
```jsx
database_type: "sqlite",
database_database: "./medusa-db.sql",
```
Then, migrate the database schema to the new PostgreSQL database:
```bash
medusa migrations run
```
:::tip
When changing from SQLite to Postgres, you should seed the database again using:
If you want to add demo data into your server, you should also seed the database using the following command:
```bash npm2yarn
npm run seed
```
:::
## Additional Resources
- Learn how to [set up your development environment](../tutorial/0-set-up-your-development-environment.mdx).
- Learn how to [configure your server](../usage/configurations.md).
- Learn more about [the Medusa CLI tool](../cli/reference.md).