Skip to content

Update Strapi documentation for v4.5.0 release #24

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ displayed_sidebar: cmsSidebar
tags:
- breaking changes
- database
- PostgreSQL
- SQLite
- upgrade to Strapi 5
---

Expand All @@ -17,49 +17,82 @@ import MigrationIntro from '/docs/snippets/breaking-change-page-migration-intro.

Strapi 5 can only use the `better-sqlite3` package for SQLite databases, and the `client` value for it must be set to `sqlite`.

<Intro />

<BreakingChangeIdCard
codemodName="sqlite3-to-better-sqlite3"
codemodLink="https://github.com/strapi/strapi/blob/develop/packages/utils/upgrade/resources/codemods/5.0.0/sqlite3-to-better-sqlite3.json.ts"
/>



## Breaking change description

<SideBySideContainer>

<SideBySideColumn>



**In Strapi v4**

The database configuration `client` option for SQLite databases accepts several values such as `sqlite3`, `vscode/sqlite3`, `sqlite-legacy`, and `better-sqlite3`.

</SideBySideColumn>

<SideBySideColumn>



**In Strapi 5**

The database configuration `client` option for SQLite database only accepts `sqlite`.

</SideBySideColumn>

</SideBySideContainer>



## Migration

<MigrationIntro />


### Notes

* Strapi 5 uses the `better-sqlite3` package for SQLite databases under the hood and rewrites the `sqlite` option as `better-sqlite3` for Knex.
* Additional information about database clients and configuration can be found in the [database configuration](/cms/configurations/database) documentation.

### Automated procedure

The [upgrade tool](/cms/upgrade-tool) provides codemods that will automatically handle this change for you. It's recommended to use this tool for a smooth migration process.

### Manual procedure

No manual migration should be required as codemods from the [upgrade tool](/cms/upgrade-tool) will handle this change.
If you prefer to manually migrate or if the automated procedure doesn't cover your specific use case, follow these steps:

1. Update your database configuration:
Open your database configuration file (typically `config/database.js` or `config/database.ts`) and change the `client` option to `sqlite`:

```javascript
module.exports = ({ env }) => ({
connection: {
client: 'sqlite',
// ... other configuration options
},
});
```

2. Update your dependencies:
Run the following commands in your terminal:

```bash
# Remove the sqlite3 package if it's installed
yarn remove sqlite3

# Install the better-sqlite3 package
yarn add better-sqlite3
```

3. Update your code:
If you have any custom code that explicitly uses `sqlite3`, you'll need to update it to use `better-sqlite3` instead. Refer to the [`better-sqlite3` documentation](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md) for the updated API.

4. Test your application:
After making these changes, thoroughly test your application to ensure that all database operations are working as expected.

## Additional considerations

In case you want to manually migrate, run the following commands in the terminal:
- If you're using any plugins or custom code that depend on specific SQLite implementations, ensure they are compatible with `better-sqlite3`.
- Review your deployment process and update any scripts or configurations that might be affected by this change.
- If you're using SQLite in a production environment, consider the performance implications and benefits of switching to `better-sqlite3`.

1. Run `yarn remove sqlite3` to remove the sqlite 3 package.
2. Run `yarn add better-sqlite3` to install the `better-sqlite3` package.
By following these steps, you should be able to successfully migrate your Strapi application to use the `better-sqlite3` package for SQLite databases in Strapi 5.