SQLite 客户端仅支持 better-sqlite3 包

页面摘要: 在 Strapi 5 中,SQLite 数据库必须使用 better-sqlite3 包,且数据库客户端配置必须设置为 sqlite,而非 sqlite3 或 sqlite-legacy 等其他选项。

Strapi 5 只能使用 better-sqlite3 包用于 SQLite 数据库,且其 client 值必须设置为 sqlite。

本页面是破坏性变更数据库的一部分,提供有关该破坏性变更的信息,以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

代码迁移工具: sqlite3-to-better-sqlite3

破坏性变更说明

在 Strapi v4 中

SQLite 数据库的数据库配置 client 选项接受多个值,如 sqlite3、vscode/sqlite3、sqlite-legacy 和 better-sqlite3。

在 Strapi 5 中

SQLite 数据库的数据库配置 client 选项只接受 sqlite。

迁移

本节汇总了关于该破坏性变更的有用说明和操作步骤。

说明

  • Strapi 5 在底层使用 better-sqlite3 包用于 SQLite 数据库,并将 sqlite 选项改写为供 Knex 使用的 better-sqlite3。
  • 有关数据库客户端和配置的更多信息,可在 数据库配置 文档中找到。

手动操作步骤

由于 升级工具 中的 codemod 会处理此变更,应无需手动迁移。

如果你希望手动迁移,请在终端中运行以下命令:

  1. 运行 yarn remove sqlite3 以移除 sqlite 3 包。
  2. 运行 yarn add better-sqlite3 以安装 better-sqlite3 包。