Bindings depending on the environment
I have some bindings in my wrangler.toml:
I would like to specify a different database for the preview env (when deploying on a different branch than main) BUT to keep the same binding. Ideally it would look like these:
I have digged in the doc and tried various things. This seems not possible.
Of course you can have different binding name but then you have to change your code so it's of no help.
Thx in advance for sharing your experience on this.
1 Reply
This should work just how you have it,
[[env.preview.d1_databases]]
.
Checking my own code, I have the database_id
field in both binding sections as well as database_name
, so maybe that is necessary? I do use the same binding name for both environments, with a different name and id, and it works as expected.