I'm trying to get a SQLite-backed DO to

I'm trying to get a SQLite-backed DO to work locally, but I keep running into this error message when I run my vitest test suite locally:
Error: SQL is not enabled for this Durable Object class. To enable it, set `enableSql = true` in your workerd config for the class. If using wrangler, under `[[migrations]]` in wrangler.toml, change `new_classes` to `new_sqlite_classes`. Note that this change cannot be made after the class is already deployed to production.
Error: SQL is not enabled for this Durable Object class. To enable it, set `enableSql = true` in your workerd config for the class. If using wrangler, under `[[migrations]]` in wrangler.toml, change `new_classes` to `new_sqlite_classes`. Note that this change cannot be made after the class is already deployed to production.
Here is the relevant snippet from my wrangler.test.toml file:
bindings = [
{ name = "ROOM_DO", class_name = "Room" },
{ name = "SQLROOM_DO", class_name = "SQLRoom" },
]

[[migrations]]
tag = "v1"
new_classes = ["Room", "Legacy"]

[[migrations]]
tag = "v2"
deleted_classes = ["Legacy"]

[[migrations]]
tag = "v3"
new_sqlite_classes = ["SQLRoom"]
bindings = [
{ name = "ROOM_DO", class_name = "Room" },
{ name = "SQLROOM_DO", class_name = "SQLRoom" },
]

[[migrations]]
tag = "v1"
new_classes = ["Room", "Legacy"]

[[migrations]]
tag = "v2"
deleted_classes = ["Legacy"]

[[migrations]]
tag = "v3"
new_sqlite_classes = ["SQLRoom"]
And here is how I'm including it from my Vitest config:
export default defineWorkersConfig({
...,
test: {
...,
poolOptions: {
...,
workers: {
...,
wrangler: {
configPath: "./wrangler.test.toml"
},
},
},
},
});
export default defineWorkersConfig({
...,
test: {
...,
poolOptions: {
...,
workers: {
...,
wrangler: {
configPath: "./wrangler.test.toml"
},
},
},
},
});
What am I doing wrong here?
1 Reply
Vincent
VincentOP3w ago
From reading the workerd source code, I read that setting the "experimental" compat option in miniflare also does the trick, although not recommended. I can confirm this works:
export default defineWorkersConfig({
...,
test: {
...,
poolOptions: {
...,
workers: {
...,
miniflare: {
compatibilityFlags: [
...,
"experimental"
],
},
},
},
},
});
export default defineWorkersConfig({
...,
test: {
...,
poolOptions: {
...,
workers: {
...,
miniflare: {
compatibilityFlags: [
...,
"experimental"
],
},
},
},
},
});
However, I'd like to configure it in the preferred way. Can anyone tell me where I need to configure this enableSql: true setting?

Did you find this page helpful?