Skip to content

Commit

Permalink
Remove docs for db command
Browse files Browse the repository at this point in the history
  • Loading branch information
callingmedic911 committed Jul 22, 2021
1 parent 10ef2a9 commit f5eeda9
Showing 1 changed file with 0 additions and 192 deletions.
192 changes: 0 additions & 192 deletions docs/cliCommands.md
Expand Up @@ -159,198 +159,6 @@ If an error occurs during script execution, any remaining scripts are skipped an
yarn redwood dataMigrate up
```

## db

Database tools.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```
yarn redwood db <command>
```

<br/>

<!-- new command? link? deprecated b4... -->

| Command | Description |
| :----------------- | :---------------------------------------------------------------------------------------------------- |
| `down [decrement]` | Migrate your database down |
| `generate` | Generate the Prisma client |
| `introspect` | Introspect your database and generate models in `./api/db/schema.prisma`, overwriting existing models |
| `save [name..]` | Create a new migration |
| `seed` | Seed your database with test data |
| `studio` | Start Prisma Studio |
| `up [increment]` | Generate the Prisma client and apply migrations |

### db down

Migrate your database down.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db down [decrement]
```

<br/>

| Argument | Description |
| :---------- | :------------------------------------------------------- |
| `decrement` | Number of backwards migrations to apply. Defaults to `1` |

**Example**

Given the following migrations,

```plaintext{2,4}
api/db/migrations/
├── 20200518160457-create-users <-- desired
├── 20200518160621-add-profiles
├── 20200518160811-add-posts <-- current
└── migrate.lock
```

we could get to `20200518160457-create-users` by running:

```terminal
~/redwood-app$ yarn redwood db down 2
```

### db generate

Generate the Prisma client.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db generate
```

The Prisma client is auto-generated and tailored to your `schema.prisma`.
This means that `yarn redwood db generate` needs to be run after every change to your `schema.prisma` for your Prisma client to be up to date. But you usually won't have to do this manually as other Redwood commands run this behind the scenes.

### db introspect

Introspect your database and generate models in `./api/db/schema.prisma`, overwriting existing models.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db introspect
```

### db save

Create a new migration.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db save [name..]
```

A migration defines the steps necessary to update your current schema.

| Argument | Description |
| :------- | :-------------------- |
| `name` | Name of the migration |

Running `yarn redwood db save` generates the following directories and files as necessary:

```terminal
api/db/migrations
├── 20200516162516-create-users
│ ├── README.md
│ ├── schema.prisma
│ └── steps.json
└── migrate.lock
```

<br/>

- `migrations`: A directory to store migrations.
- `migrations/<migration>`: A directory for a specific migration. The name (`<migration>`) is composed of a timestamp of when it was created and the name given during `yarn redwood db save`.
- `migrations/<migration>/README.md`: A human-readable description of the migration, including metadata like when the migration was created and by who, a list of the actual migration changes, and a diff of the changes made to `schema.prisma`.
- `migrations/<migration>/schema.prisma`: The schema that will be created if the migration is applied.
- `migrations/<migration>/steps.json`: An alternate representation of the migration steps that will be applied.
- `migrate.lock`: A lock file specifying the current migration.

### db seed

Seed your database with test data.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood prisma db seed
```

Runs `seed.js` in `./api/db`. `seed.js` instantiates the Prisma client and provides an async main function where you can put any seed data&mdash;data that needs to exist for your app to run. See the [example blog's seed.js file](https://github.com/redwoodjs/example-blog/blob/master/api/db/seed.js).

### db studio

Start <a href="https://github.com/prisma/studio">Prisma Studio</a>, a visual editor for your database.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db studio
```

### db up

Generate the Prisma client and apply migrations.

> **WARNING**
>
> As of `v0.25`, `yarn redwood db <command>` has been deprecated in favor of `yarn redwood prisma <command>`. Click [here](#prisma) to skip to the prisma section below.
```terminal
yarn redwood db up [increment]
```

<br/>

| Arguments & Options | Description |
| :------------------ | :------------------------------------------------------------ |
| `increment` | Number of forward migrations to apply. Defaults to the latest |
| `--autoApprove` | Skip interactive approval before migrating |
| `--dbClient` | Generate the Prisma client |
| `--verbose` | Print more |

**Example**

Given the following migrations

```plaintext{2,4}
api/db/migrations/
├── 20200518160457-create-users <-- current
├── 20200518160621-add-profiles
├── 20200518160811-add-posts <-- desired
└── migrate.lock
```

we could get to `20200518160811-add-posts` by running:

```terminal
~/redwood-app$ yarn redwood db up 2
```

## dev

Start development servers for api and web.
Expand Down

0 comments on commit f5eeda9

Please sign in to comment.