Skip to content

Commit 0b2506c

Browse files
committed
Resolving merge conflict, adding global commands once at the bottom.
1 parent a0dfc1c commit 0b2506c

File tree

2 files changed

+5
-317
lines changed

2 files changed

+5
-317
lines changed

src/content/docs/workers/wrangler/commands.mdx

Lines changed: 1 addition & 315 deletions
Original file line numberDiff line numberDiff line change
@@ -183,321 +183,7 @@ wrangler generate [<NAME>] [TEMPLATE]
183183

184184
Interact with Cloudflare's D1 service.
185185

186-
### `create`
187-
188-
Creates a new D1 database, and provides the binding and UUID that you will put in your `wrangler.toml` file.
189-
190-
```txt
191-
wrangler d1 create <DATABASE_NAME> [OPTIONS]
192-
```
193-
194-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
195-
- The name of the new D1 database.
196-
- `--location` <Type text="string" /> <MetaInfo text="optional" />
197-
- Provide an optional [location hint](/d1/configuration/data-location/) for your database leader.
198-
- Available options include `weur` (Western Europe), `eeur` (Eastern Europe), `apac` (Asia Pacific), `oc` (Oceania), `wnam` (Western North America), and `enam` (Eastern North America).
199-
200-
<Render file="wrangler-commands/global-flags" product="workers" />
201-
202-
### `info`
203-
204-
Get information about a D1 database, including the current database size and state.
205-
206-
```txt
207-
wrangler d1 info <DATABASE_NAME> [OPTIONS]
208-
```
209-
210-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
211-
- The name of the D1 database to get information about.
212-
- `--json` <Type text="boolean" /> <MetaInfo text="optional" />
213-
- Return output as JSON rather than a table.
214-
215-
<Render file="wrangler-commands/global-flags" product="workers" />
216-
217-
### `list`
218-
219-
List all D1 databases in your account.
220-
221-
```txt
222-
wrangler d1 list [OPTIONS]
223-
```
224-
225-
- `--json` <Type text="boolean" /> <MetaInfo text="optional" />
226-
- Return output as JSON rather than a table.
227-
228-
<Render file="wrangler-commands/global-flags" product="workers" />
229-
230-
### `delete`
231-
232-
Delete a D1 database.
233-
234-
```txt
235-
wrangler d1 delete <DATABASE_NAME> [OPTIONS]
236-
```
237-
238-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
239-
- The name of the D1 database to delete.
240-
- `-y, --skip-confirmation` <Type text="boolean" /> <MetaInfo text="optional" />
241-
- Skip deletion confirmation prompt.
242-
243-
<Render file="wrangler-commands/global-flags" product="workers" />
244-
245-
### `execute`
246-
247-
Execute a query on a D1 database.
248-
249-
```txt
250-
wrangler d1 execute <DATABASE_NAME> [OPTIONS]
251-
```
252-
253-
:::note
254-
255-
You must provide either `--command` or `--file` for this command to run successfully.
256-
257-
:::
258-
259-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
260-
- The name of the D1 database to execute a query on.
261-
- `--command` <Type text="string" /> <MetaInfo text="optional" />
262-
- The SQL query you wish to execute.
263-
- `--file` <Type text="string" /> <MetaInfo text="optional" />
264-
- Path to the SQL file you wish to execute.
265-
- `-y, --yes` <Type text="boolean" /> <MetaInfo text="optional" />
266-
- Answer `yes` to any prompts.
267-
- `--local` <Type text="boolean" /> <MetaInfo text="(default: true) optional" />
268-
- Execute commands/files against a local database for use with [wrangler dev](#dev).
269-
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
270-
- Execute commands/files against a remote D1 database for use with [wrangler dev --remote](#dev).
271-
- `--persist-to` <Type text="string" /> <MetaInfo text="optional" />
272-
- Specify directory to use for local persistence (for use in combination with `--local`).
273-
- `--json` <Type text="boolean" /> <MetaInfo text="optional" />
274-
- Return output as JSON rather than a table.
275-
- `--preview` <Type text="boolean" /> <MetaInfo text="optional" />
276-
- Execute commands/files against a preview D1 database (as defined by `preview_database_id` in [Wrangler.toml](/workers/wrangler/configuration/#d1-databases)).
277-
- `--batch-size` <Type text="number" /> <MetaInfo text="optional" />
278-
- Number of queries to send in a single batch.
279-
280-
<Render file="wrangler-commands/global-flags" product="workers" />
281-
282-
### `export`
283-
284-
Export a D1 database or table's schema and/or content to a `.sql` file.
285-
286-
```txt
287-
wrangler d1 export <DATABASE_NAME> [OPTIONS]
288-
```
289-
290-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
291-
- The name of the D1 database to export.
292-
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
293-
- Execute commands/files against a remote D1 database for use with [wrangler dev --remote](#dev).
294-
- `--output` <Type text="string" /> <MetaInfo text="optional" />
295-
- Path to the SQL file for your export.
296-
- `--table` <Type text="string" /> <MetaInfo text="optional" />
297-
- The name of the table within a D1 database to export.
298-
- `--no-data` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
299-
- Controls whether export SQL file contains database data. Note that `--no-data=true` is not recommended due to a known wrangler limitation that intreprets the value as false.
300-
- `--no-schema` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
301-
- Controls whether export SQL file contains database schema. Note that `--no-schema=true` is not recommended due to a known wrangler limitation that intreprets the value as false.
302-
303-
<Render file="wrangler-commands/global-flags" product="workers" />
304-
305-
### `time-travel restore`
306-
307-
Restore a database to a specific point-in-time using [Time Travel](/d1/reference/time-travel/).
308-
309-
```txt
310-
wrangler d1 time-travel restore <DATABASE_NAME> [OPTIONS]
311-
```
312-
313-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
314-
- The name of the D1 database to execute a query on.
315-
- `--bookmark` <Type text="string" /> <MetaInfo text="optional" />
316-
- A D1 bookmark representing the state of a database at a specific point in time.
317-
- `--timestamp` <Type text="string" /> <MetaInfo text="optional" />
318-
- A UNIX timestamp or JavaScript date-time `string` within the last 30 days.
319-
- `--json` <Type text="boolean" /> <MetaInfo text="optional" />
320-
- Return output as JSON rather than a table.
321-
322-
<Render file="wrangler-commands/global-flags" product="workers" />
323-
324-
### `time-travel info`
325-
326-
Inspect the current state of a database for a specific point-in-time using [Time Travel](/d1/reference/time-travel/).
327-
328-
```txt
329-
wrangler d1 time-travel info <DATABASE_NAME> [OPTIONS]
330-
```
331-
332-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
333-
- The name of the D1 database to execute a query on.
334-
- `--timestamp` <Type text="string" /> <MetaInfo text="optional" />
335-
- A UNIX timestamp or JavaScript date-time `string` within the last 30 days.
336-
- `--json` b<Type text="boolean" /> <MetaInfo text="optional" />
337-
- Return output as JSON rather than a table.
338-
339-
<Render file="wrangler-commands/global-flags" product="workers" />
340-
341-
### `backup create`
342-
343-
:::caution
344-
345-
This command only works on databases created during D1's alpha period. You can check which version your database uses with `wrangler d1 info <DATABASE_NAME>`.
346-
347-
This command will not work on databases that are created during the beta period, or after general availability (GA). Refer to [Time Travel](/d1/reference/time-travel/) in the D1 documentation for more information on D1's approach to backup and restores for databases created during the beta/GA period.
348-
:::
349-
350-
Initiate a D1 backup.
351-
352-
```txt
353-
wrangler d1 backup create <DATABASE_NAME>
354-
```
355-
356-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
357-
- The name of the D1 database to backup.
358-
359-
<Render file="wrangler-commands/global-flags" product="workers" />
360-
361-
### `backup list`
362-
363-
:::caution
364-
365-
This command only works on databases created during D1's alpha period. You can check which version your database uses with `wrangler d1 info <DATABASE_NAME>`.
366-
367-
This command will not work on databases that are created during the beta period, or after general availability (GA). Refer to [Time Travel](/d1/reference/time-travel/) in the D1 documentation for more information on D1's approach to backup and restores for databases created during the beta/GA period.
368-
:::
369-
370-
List all available backups.
371-
372-
```txt
373-
wrangler d1 backup list <DATABASE_NAME>
374-
```
375-
376-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
377-
- The name of the D1 database to list the backups of.
378-
379-
<Render file="wrangler-commands/global-flags" product="workers" />
380-
381-
### `backup restore`
382-
383-
:::caution
384-
385-
This command only works on databases created during D1's alpha period. You can check which version your database uses with `wrangler d1 info <DATABASE_NAME>`.
386-
387-
This command will not work on databases that are created during the beta period, or after general availability (GA). Refer to [Time Travel](/d1/reference/time-travel/) in the D1 documentation for more information on D1's approach to backup and restores for databases created during the beta/GA period.
388-
:::
389-
390-
Restore a backup into a D1 database.
391-
392-
```txt
393-
wrangler d1 backup restore <DATABASE_NAME> <BACKUP_ID>
394-
```
395-
396-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
397-
- The name of the D1 database to restore the backup into.
398-
- `BACKUP_ID` <Type text="string" /> <MetaInfo text="required" />
399-
- The ID of the backup you wish to restore.
400-
401-
<Render file="wrangler-commands/global-flags" product="workers" />
402-
403-
### `backup download`
404-
405-
:::caution
406-
407-
This command only works on databases created during D1's alpha period. You can check which version your database uses with `wrangler d1 info <DATABASE_NAME>`.
408-
409-
This command will not work on databases that are created during the beta period, or after general availability (GA). To download existing data of a beta/GA database to your local machine refer to the `wrangler d1 export` command. Refer to [Time Travel](/d1/reference/time-travel/) in the D1 documentation for more information on D1's approach to backups for databases created during the beta/GA period.
410-
:::
411-
412-
Download existing data to your local machine.
413-
414-
```txt
415-
wrangler d1 backup download <DATABASE_NAME> <BACKUP_ID>
416-
```
417-
418-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
419-
- The name of the D1 database you wish to download the backup of.
420-
- `BACKUP_ID` <Type text="string" /> <MetaInfo text="required" />
421-
- The ID of the backup you wish to download.
422-
- `--output` <Type text="string" /> <MetaInfo text="optional" />
423-
- The `.sqlite3` file to write to (defaults to `'<DB_NAME>.<SHORT_BACKUP_ID>.sqlite3'`).
424-
425-
<Render file="wrangler-commands/global-flags" product="workers" />
426-
427-
### `migrations create`
428-
429-
Create a new migration.
430-
431-
This will generate a new versioned file inside the `migrations` folder. Name your migration file as a description of your change. This will make it easier for you to find your migration in the `migrations` folder. An example filename looks like:
432-
433-
`0000_create_user_table.sql`
434-
435-
The filename will include a version number and the migration name you specify below.
436-
437-
```txt
438-
wrangler d1 migrations create <DATABASE_NAME> <MIGRATION_NAME>
439-
```
440-
441-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
442-
- The name of the D1 database you wish to create a migration for.
443-
- `MIGRATION_NAME` <Type text="string" /> <MetaInfo text="required" />
444-
- A descriptive name for the migration you wish to create.
445-
446-
<Render file="wrangler-commands/global-flags" product="workers" />
447-
448-
### `migrations list`
449-
450-
View a list of unapplied migration files.
451-
452-
```txt
453-
wrangler d1 migrations list <DATABASE_NAME> [OPTIONS]
454-
```
455-
456-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
457-
- The name of the D1 database you wish to list unapplied migrations for.
458-
- `--local` <Type text="boolean" /> <MetaInfo text="optional" />
459-
- Show the list of unapplied migration files on your locally persisted D1 database.
460-
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
461-
- Show the list of unapplied migration files on your remote D1 database.
462-
- `--persist-to` <Type text="string" /> <MetaInfo text="optional" />
463-
- Specify directory to use for local persistence (for use in combination with `--local`).
464-
- `--preview` <Type text="boolean" /> <MetaInfo text="optional" />
465-
- Show the list of unapplied migration files on your preview D1 database (as defined by `preview_database_id` in [`wrangler.toml`](/workers/wrangler/configuration/#d1-databases)).
466-
467-
<Render file="wrangler-commands/global-flags" product="workers" />
468-
469-
### `migrations apply`
470-
471-
Apply any unapplied migrations.
472-
473-
This command will prompt you to confirm the migrations you are about to apply. Confirm that you would like to proceed. After, a backup will be captured.
474-
475-
The progress of each migration will be printed in the console.
476-
477-
When running the apply command in a CI/CD environment or another non-interactive command line, the confirmation step will be skipped, but the backup will still be captured.
478-
479-
If applying a migration results in an error, this migration will be rolled back, and the previous successful migration will remain applied.
480-
481-
```txt
482-
wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS]
483-
```
484-
485-
- `DATABASE_NAME` <Type text="string" /> <MetaInfo text="required" />
486-
- The name of the D1 database you wish to apply your migrations on.
487-
- `--env` <Type text="string" /> <MetaInfo text="optional" />
488-
- Specify which environment configuration to use for D1 binding
489-
- `--local` <Type text="boolean" /> <MetaInfo text="(default: true) optional" />
490-
- Execute any unapplied migrations on your locally persisted D1 database.
491-
- `--remote` <Type text="boolean" /> <MetaInfo text="(default: false) optional" />
492-
- Execute any unapplied migrations on your remote D1 database.
493-
- `--persist-to` <Type text="string" /> <MetaInfo text="optional" />
494-
- Specify directory to use for local persistence (for use in combination with `--local`).
495-
- `--preview` <Type text="boolean" /> <MetaInfo text="optional" />
496-
- Execute any unapplied migrations on your preview D1 database (as defined by `preview_database_id` in [`wrangler.toml`](/workers/wrangler/configuration/#d1-databases)).
497-
- `--batch-size` <Type text="number" /> <MetaInfo text="optional" />
498-
- Number of queries to send in a single batch.
499-
500-
<Render file="wrangler-commands/global-flags" product="workers" />
186+
<Render file="wrangler-commands/d1" product="workers" />
501187

502188
---
503189

src/content/partials/workers/wrangler-commands/d1.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{}
33
---
44

5-
import { AnchorHeading, Type, MetaInfo } from "~/components";
5+
import {Render, AnchorHeading, Type, MetaInfo } from "~/components";
66

77
<AnchorHeading title="`create`" slug="d1-create" depth={3} />
88

@@ -290,4 +290,6 @@ wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS]
290290
- `--batch-size` <Type text="number" /> <MetaInfo text="optional" />
291291
- Number of queries to send in a single batch.
292292

293-
---
293+
## Global commands
294+
295+
<Render file="wrangler-commands/global-flags" product="workers" />

0 commit comments

Comments
 (0)