diff --git a/src/content/partials/workers/wrangler-commands/d1.mdx b/src/content/partials/workers/wrangler-commands/d1.mdx index 312d0fcc495f93d..514999c3aa5ba7f 100644 --- a/src/content/partials/workers/wrangler-commands/d1.mdx +++ b/src/content/partials/workers/wrangler-commands/d1.mdx @@ -2,226 +2,6 @@ {} --- -import { Render, AnchorHeading, Type, MetaInfo } from "~/components"; +import { WranglerNamespace } from "~/components"; - - -Creates a new D1 database, and provides the binding and UUID that you will put in your Wrangler file. - -```txt -wrangler d1 create [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the new D1 database. -- `--location` - - Provide an optional [location hint](/d1/configuration/data-location/) for your database leader. - - Available options include `weur` (Western Europe), `eeur` (Eastern Europe), `apac` (Asia Pacific), `oc` (Oceania), `wnam` (Western North America), and `enam` (Eastern North America). - - - -Get information about a D1 database, including the current database size and state. - -```txt -wrangler d1 info [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database to get information about. -- `--json` - - Return output as JSON rather than a table. - - - -List all D1 databases in your account. - -```txt -wrangler d1 list [OPTIONS] -``` - -- `--json` - - Return output as JSON rather than a table. - - - -Delete a D1 database. - -```txt -wrangler d1 delete [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database to delete. -- `-y, --skip-confirmation` - - Skip deletion confirmation prompt. - - - -Execute a query on a D1 database. - -```txt -wrangler d1 execute [OPTIONS] -``` - -:::note - -You must provide either `--command` or `--file` for this command to run successfully. - -::: - -- `DATABASE_NAME` - - The name of the D1 database to execute a query on. -- `--command` - - The SQL query you wish to execute. -- `--file` - - Path to the SQL file you wish to execute. -- `-y, --yes` - - Answer `yes` to any prompts. -- `--local` - - Execute commands/files against a local database for use with [wrangler dev](/workers/wrangler/commands/#dev). -- `--remote` - - Execute commands/files against a remote D1 database for use with [remote bindings](/workers/development-testing/#remote-bindings) or your deployed Worker. -- `--persist-to` - - Specify directory to use for local persistence (for use in combination with `--local`). -- `--json` - - Return output as JSON rather than a table. -- `--preview` - - Execute commands/files against a preview D1 database (as defined by `preview_database_id` in the [Wrangler configuration file](/workers/wrangler/configuration/#d1-databases)). - - - -Export a D1 database or table's schema and/or content to a `.sql` file. - -```txt -wrangler d1 export [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database to export. -- `--local` - - Export from a local database for use with [wrangler dev](/workers/wrangler/commands/#dev). -- `--remote` - - Export from a remote D1 database. -- `--output` - - Path to the SQL file for your export. -- `--table` - - The name of the table within a D1 database to export. -- `--no-data` - - 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. -- `--no-schema` - - 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. - - - -Restore a database to a specific point-in-time using [Time Travel](/d1/reference/time-travel/). - -```txt -wrangler d1 time-travel restore [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database to execute a query on. -- `--bookmark` - - A D1 bookmark representing the state of a database at a specific point in time. -- `--timestamp` - - A UNIX timestamp or JavaScript date-time `string` within the last 30 days. -- `--json` - - Return output as JSON rather than a table. - - - -Inspect the current state of a database for a specific point-in-time using [Time Travel](/d1/reference/time-travel/). - -```txt -wrangler d1 time-travel info [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database to execute a query on. -- `--timestamp` - - A UNIX timestamp or JavaScript date-time `string` within the last 30 days. -- `--json` b - - Return output as JSON rather than a table. - - - -Create a new migration. - -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: - -`0000_create_user_table.sql` - -The filename will include a version number and the migration name you specify below. - -```txt -wrangler d1 migrations create -``` - -- `DATABASE_NAME` - - The name of the D1 database you wish to create a migration for. -- `MIGRATION_NAME` - - A descriptive name for the migration you wish to create. - - - -View a list of unapplied migration files. - -```txt -wrangler d1 migrations list [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database you wish to list unapplied migrations for. -- `--local` - - Show the list of unapplied migration files on your locally persisted D1 database. -- `--remote` - - Show the list of unapplied migration files on your remote D1 database. -- `--persist-to` - - Specify directory to use for local persistence (for use in combination with `--local`). -- `--preview` - - Show the list of unapplied migration files on your preview D1 database (as defined by `preview_database_id` in the [Wrangler configuration file](/workers/wrangler/configuration/#d1-databases)). - - - -Apply any unapplied migrations. - -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. - -The progress of each migration will be printed in the console. - -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. - -If applying a migration results in an error, this migration will be rolled back, and the previous successful migration will remain applied. - -```txt -wrangler d1 migrations apply [OPTIONS] -``` - -- `DATABASE_NAME` - - The name of the D1 database you wish to apply your migrations on. -- `--env` - - Specify which environment configuration to use for D1 binding -- `--local` - - Execute any unapplied migrations on your locally persisted D1 database. -- `--remote` - - Execute any unapplied migrations on your remote D1 database. -- `--persist-to` - - Specify directory to use for local persistence (for use in combination with `--local`). -- `--preview` - - Execute any unapplied migrations on your preview D1 database (as defined by `preview_database_id` in the [Wrangler configuration file](/workers/wrangler/configuration/#d1-databases)). +