Hey folks - trying to migrate from the

Hey folks - trying to migrate from the previous setupDevBindings to the new setupDevPlatform - I've got it working except it seems to not be pointing at the correct local sqlite DB for the D1 driver. This was my previous config file, have I not specified the wrangler toml correctly?
setupDevBindings({
bindings: {
D1: {
type: "d1",
databaseName: "podcast-stats-prod",
id: "e2659b9a-928c-4218-beb5-518b87f59c4f",
},
},
});
setupDevBindings({
bindings: {
D1: {
type: "d1",
databaseName: "podcast-stats-prod",
id: "e2659b9a-928c-4218-beb5-518b87f59c4f",
},
},
});
[[d1_databases]]
binding = "D1"
database_name = "podcast-stats-prod"
database_id = "e2659b9a-928c-4218-beb5-518b87f59c4f"
[[d1_databases]]
binding = "D1"
database_name = "podcast-stats-prod"
database_id = "e2659b9a-928c-4218-beb5-518b87f59c4f"
10 Replies
wesbos
wesbosOP13mo ago
Its just creating a new blank DB when I run this code, so I must have the settings mixed up
kian
kian13mo ago
I suspect D1 should be an array of objects, not just an object - but if you're saying it works but not exactly how it should then I'm not sure.
wesbos
wesbosOP13mo ago
Hmm yeah, its connecting fine, Just to the wrong DB I might just rename the files, but I'd like to know if my config is wrong
kian
kian13mo ago
No description
kian
kian13mo ago
At a glance, the databaseId and databaseName options seem exclusive
kian
kian13mo ago
No description
kian
kian13mo ago
This is how the setupDevBindings builds a configuration to pass to Wrangler This might be the same bug(?) that Miniflare had before. Try this
setupDevBindings({
bindings: {
D1: {
type: "d1",
databaseId: "e2659b9a-928c-4218-beb5-518b87f59c4f"
},
},
});
setupDevBindings({
bindings: {
D1: {
type: "d1",
databaseId: "e2659b9a-928c-4218-beb5-518b87f59c4f"
},
},
});
wesbos
wesbosOP13mo ago
So I should only pass ID?
kian
kian13mo ago
Yeah With Miniflare, you pass both - setupDevBindings only supports one or the other. In this case, it doesn't see your ID - it only sees the database name.
wesbos
wesbosOP13mo ago
hmm okay thanks

Did you find this page helpful?