# Push a database or uploads to staging

> Send your local database or uploads to staging or a preview with the DDEV add-on, or only some tables. Code goes by Git, and live never takes a push.

Source: https://docs.wpwaterfall.com/push-code-to-staging

`ddev wpwaterfall push` sends parts of your local copy to staging or a preview. Code goes by Git, the same way with or without DDEV: see [How Git deploys work](https://docs.wpwaterfall.com/code/git-workflow#change-code-and-push). Live never takes a push: see [Why does live refuse a push?](https://docs.wpwaterfall.com/code/git-workflow#why-does-live-refuse-a-push). A data push moves the database and uploads only, and never runs your code.

## How do I push data?

`ddev wpwaterfall push --db --uploads` sends your local data. Code and data are separate choices: `--code`, `--db`, `--uploads`, or `--all`.

Data pushes replace what is on the environment, so the add-on is careful:

1. It names the environment and what will be replaced, and asks you to type the environment name. `--yes` skips the question.
2. It takes a backup of the environment through WP Waterfall first. You find it under **Backups**.
3. It keeps a copy of the remote database in the SSH user's home folder, as `~/wpwaterfall-pre-push-STAMP.sql.gz`, before it replaces it.
4. It sends the database with your local address rewritten to the environment's address. Your local database is not changed.
5. It copies uploads without removing anything on the server, and without caches or PHP files.

A database push replaces the whole database, including users, orders, and comments on staging. If someone else is working on staging, tell them first.

### Push only some tables

To replace a few tables and leave the rest alone, name them:

```bash
ddev wpwaterfall push --db --tables wp_posts,wp_postmeta
```

The add-on lists the tables with their local row counts and asks you to type the environment name. It takes the same backup first. Only those tables change on the environment, with your local address rewritten in them.

- Each name must start with the site's table prefix, use letters, digits, and underscores, and exist in your local database.
- `wp_users`, `wp_usermeta`, and `wp_options` are refused. Add `--allow-sensitive` if you mean to replace one.
- A network pushes whole, so `--tables` is refused there.

## API

- `POST /v1/environments/{id}/local-dev/push-session`: records the push in the activity log, refuses live with `live_is_immutable`, and returns the plan. A database or uploads push starts with a required backup.
- `POST /v1/environments/{id}/backups`: the backup the add-on takes first.
- `GET /v1/environments/{id}/local-dev`: says which parts an environment lets you push.

## Related

- [Develop locally with DDEV](https://docs.wpwaterfall.com/develop-locally-with-ddev)
- [Pull code, a database, and uploads](https://docs.wpwaterfall.com/pull-a-database-and-files)
- [How Git deploys work](https://docs.wpwaterfall.com/code/git-workflow)
- [Backups](https://docs.wpwaterfall.com/backups)
