Skip to content

Commit 5aef8da

Browse files
committed
Implementing feedback round 2
1 parent b51ac8e commit 5aef8da

File tree

1 file changed

+61
-10
lines changed

1 file changed

+61
-10
lines changed

src/content/docs/d1/get-started.mdx

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ After correctly preparing your [Wrangler configuration file](/workers/wrangler/c
256256
```sh
257257
npx wrangler d1 execute prod-d1-tutorial --local --file=./schema.sql
258258
```
259+
```output
260+
⛅️ wrangler 4.13.2
261+
-------------------
262+
263+
🌀 Executing on local database prod-d1-tutorial (<DATABASE_ID>) from .wrangler/state/v3/d1:
264+
🌀 To execute on your remote database, add a --remote flag to your wrangler command.
265+
🚣 3 commands executed successfully.
266+
```
259267

260268
:::note
261269
The command `npx wrangler d1 execute` initializes your database locally, not on the remote database.
@@ -269,7 +277,7 @@ After correctly preparing your [Wrangler configuration file](/workers/wrangler/c
269277

270278
```sh output
271279
🌀 Mapping SQL input into an array of statements
272-
🌀 Executing on local database production-db-backend (5f092302-3fbd-4247-a873-bf1afc5150b) from .wrangler/state/v3/d1:
280+
🌀 Executing on local database production-db-backend (<DATABASE_ID>) from .wrangler/state/v3/d1:
273281
┌────────────┬─────────────────────┬───────────────────┐
274282
│ CustomerId │ CompanyName │ ContactName │
275283
├────────────┼─────────────────────┼───────────────────┤
@@ -402,36 +410,75 @@ You can query your D1 database using your Worker.
402410
</TabItem>
403411
</Tabs>
404412

405-
## 5. Deploy your database
413+
## 5. Deploy your application
406414

407-
Deploy your database on Cloudflare's global network.
415+
Deploy your application on Cloudflare's global network.
408416

409417
<Tabs syncKey='CLIvDash'> <TabItem label='CLI'>
410418

411419
To deploy your Worker to production using Wrangler, you must first repeat the [database configuration](/d1/get-started/#populate-your-d1-database) steps after replacing the `--local` flag with the `--remote` flag to give your Worker data to read. This creates the database tables and imports the data into the production version of your database.
412420

413421
<Steps>
414-
1. Bootstrap your database with the `schema.sql` file you created in step 4:
422+
1. Create tables and add entries to your remote database with the `schema.sql` file you created in step 4. Enter `y` to confirm your decision.
415423

416424
```sh
417425
npx wrangler d1 execute prod-d1-tutorial --remote --file=./schema.sql
418426
```
427+
```sh output
428+
✔ ⚠️ This process may take some time, during which your D1 database will be unavailable to serve queries.
429+
Ok to proceed? y
430+
🚣 Executed 3 queries in 0.00 seconds (5 rows read, 6 rows written)
431+
Database is currently at bookmark 00000002-00000004-00004ef1-ad4a06967970ee3b20860c86188a4b31.
432+
┌────────────────────────┬───────────┬──────────────┬────────────────────┐
433+
│ Total queries executed │ Rows read │ Rows written │ Database size (MB) │
434+
├────────────────────────┼───────────┼──────────────┼────────────────────┤
435+
│ 3 │ 5 │ 6 │ 0.02 │
436+
└────────────────────────┴───────────┴──────────────┴────────────────────┘
437+
```
419438

420439
2. Validate the data is in production by running:
421440

422-
```sh
423-
npx wrangler d1 execute prod-d1-tutorial --remote --command="SELECT * FROM Customers"
424-
```
441+
```sh
442+
npx wrangler d1 execute prod-d1-tutorial --remote --command="SELECT * FROM Customers"
443+
```
444+
```sh output
445+
⛅️ wrangler 4.13.2
446+
-------------------
447+
448+
🌀 Executing on remote database prod-d1-tutorial (<DATABASE_ID>):
449+
🌀 To execute on your local development database, remove the --remote flag from your wrangler command.
450+
🚣 Executed 1 command in 0.4069ms
451+
┌────────────┬─────────────────────┬───────────────────┐
452+
│ CustomerId │ CompanyName │ ContactName │
453+
├────────────┼─────────────────────┼───────────────────┤
454+
│ 1 │ Alfreds Futterkiste │ Maria Anders │
455+
├────────────┼─────────────────────┼───────────────────┤
456+
│ 4 │ Around the Horn │ Thomas Hardy │
457+
├────────────┼─────────────────────┼───────────────────┤
458+
│ 11 │ Bs Beverages │ Victoria Ashworth │
459+
├────────────┼─────────────────────┼───────────────────┤
460+
│ 13 │ Bs Beverages │ Random Name │
461+
└────────────┴─────────────────────┴───────────────────┘
462+
```
425463

426464
3. Deploy your Worker to make your project accessible on the Internet. Run:
427465

428466
```sh
429467
npx wrangler deploy
430468
```
431-
432469
```sh output
433-
Outputs: https://d1-tutorial.<YOUR_SUBDOMAIN>.workers.dev
434-
```
470+
⛅️ wrangler 4.13.2
471+
-------------------
472+
473+
Total Upload: 0.19 KiB / gzip: 0.16 KiB
474+
Your worker has access to the following bindings:
475+
- D1 Databases:
476+
- DB: prod-d1-tutorial (<DATABASE_ID>)
477+
Uploaded d1-tutorial (3.76 sec)
478+
Deployed d1-tutorial triggers (2.77 sec)
479+
https://d1-tutorial.<YOUR_SUBDOMAIN>.workers.dev
480+
Current Version ID: <VERSION_ID>
481+
```
435482

436483
You can now visit the URL for your newly created project to query your live database.
437484

@@ -512,6 +559,10 @@ npx wrangler d1 delete prod-d1-tutorial
512559

513560
</TabItem> </Tabs>
514561

562+
:::caution
563+
Note that deleting your D1 database will stop your application from functioning as before.
564+
:::
565+
515566
If you want to delete your Worker:
516567

517568
<Tabs syncKey='CLIvDash'> <TabItem label='CLI'>

0 commit comments

Comments
 (0)