Environments
Environments are different contexts that your code runs in. Cloudflare Developer Platform allows you to create and manage different environments. Through environments, you can deploy the same project to multiple places under multiple names.
To specify different D1 databases for different environments, use the following syntax in your wrangler.toml
file:
In the code above, the staging
environment is using a different database (DATABASE_NAME_1
) than the production
environment (DATABASE_NAME_2
).
If you need to specify different D1 databases for different environments, your wrangler.toml
may contain bindings that resemble the following:
In the above configuration:
[[production.d1_databases]]
creates an objectproduction
with a propertyd1_databases
, whered1_databases
is an array of objects, since you can create multiple D1 bindings in case you have more than one database.- Any property below the line in the form
<key> = <value>
is a property of an object within thed1_databases
array.
Therefore, the above binding is equivalent to:
The above is equivalent to the following structure in JSON: