Deploying z0 Infrastructure
Deploying z0 Infrastructure
Section titled “Deploying z0 Infrastructure”The z0 SDK provides automation to help you manage your Cloudflare infrastructure.
Automatic Infrastructure Setup
Section titled “Automatic Infrastructure Setup”When creating a new ledger, you can use the --remote (or -r) flag to automatically update your wrangler.toml with the necessary Durable Object bindings and migrations.
z0 make:ledger Account --remoteWhat happens under the hood:
Section titled “What happens under the hood:”- File Creation:
src/ledgers/AccountLedger.tsis created from a template. - Binding Added: A new
[[durable_objects.bindings]]entry is added towrangler.toml. - Migration Added: A new
[[migrations]]entry with an incremented tag (e.g.,v2,v3) is added.
Deployment Workflow
Section titled “Deployment Workflow”After running the command with the --remote flag, follow these steps:
- Export the Ledger: Ensure your new ledger class is exported from your main entry point (e.g.,
src/index.ts). - Update Manifest: Add the new entity and its ledger to your
DomainManifest. - Deploy: Run the following command to push your changes and create the infrastructure on Cloudflare:
Terminal window wrangler deploy
Manual Infrastructure Setup
Section titled “Manual Infrastructure Setup”If you prefer to manage your configuration manually, simply omit the --remote flag and add the following blocks to your wrangler.toml:
[[durable_objects.bindings]]name = "ACCOUNT_LEDGER"class_name = "AccountLedger"
[[migrations]]tag = "vX" # Increment based on your current migrationsnew_classes = ["AccountLedger"]