Files
cloudflare_temp_email/vitepress-docs/docs/en/guide/cli/d1.md
Dream Hunter 9689a1cbca docs: clarify Pages backend URL config (#960)
* docs: clarify pages backend url setup

* docs: refine pages and d1 examples

* docs: harden pages zip generator
2026-04-07 23:59:31 +08:00

1.1 KiB

Initialize/Update D1 Database

When executing the wrangler login command for the first time, you will be prompted to log in. Follow the prompts to complete the login process.

Initialize Database

cd worker
cp wrangler.toml.template wrangler.toml
# Create D1 and execute schema.sql
wrangler d1 create temp-email-db
wrangler d1 execute temp-email-db --file=../db/schema.sql --remote

Tip

Use a project-specific database name such as temp-email-db or cloudflare-temp-email-prod so it remains easy to identify later. Avoid generic names like dev.

After creation, you can see the D1 database in the Cloudflare console.

D1

Update Database Schema

For schema updates, please confirm your previously deployed version. Check the Changelog

Find the patch file you need to execute and run it, for example:

cd worker
wrangler d1 execute temp-email-db --file=../db/2024-01-13-patch.sql --remote
wrangler d1 execute temp-email-db --file=../db/2024-04-03-patch.sql --remote