I got it working locally to Turso by patching @strapi/database with pnpm or yarn. (have not tried deploying it yet)
I made a blog post with the full guide Use Turso DB with Strapi 4
With pnpm you:
Create a patch with pnpm patch @strapi/database@4.25.9 --edit-dir strapi-db-patch
Edit the file you’re patching which will be in strapi-db-patch/dist/index.js
You need to add this to the top of the file
const Client_SQLite3 = require("knex/lib/dialects/sqlite3");
class Client_Libsql extends Client_SQLite3 {
_driver() {
return require("@libsql/sqlite3");
}
}
Object.assign(Client_Libsql.prototype, {
dialect: "libsql",
driverName: "libsql",
});
And also add a near copy of the existing SqliteDialect like this:
class LibsqlDialect extends SqliteDialect {
schemaInspector;
constructor(db) {
super(db);
this.client = "libsql";
}
configure() {}
}
Then edit the getDialectClass and getDialectName functions like this:
const getDialectClass = (client) => {
switch (client) {
case "postgres":
return PostgresDialect;
case "mysql":
return MysqlDialect;
case "sqlite":
return SqliteDialect;
case "libsql":
return LibsqlDialect;
default:
throw new Error(`Unknown dialect ${client}`);
}
};
const getDialectName = (client) => {
switch (client) {
case "postgres":
return "postgres";
case "libsql":
return "libsql";
case "mysql":
case "mysql2":
return "mysql";
case "sqlite":
case "sqlite-legacy":
return "sqlite";
default:
throw new Error(`Unknown dialect ${client}`);
}
};
Add this one line to applySearch above case “sqlite”:
// ...
case "libsql":
case "sqlite": {
// ...
The discord message limit is reached, see next post for the rest