Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
38 changes: 0 additions & 38 deletions content/clients/raw-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,45 +44,7 @@ for each transaction.
with the existing set. Optionally, a client can de-dup these keys while
merging.

## Alter the database

The `/alter` endpoint is used to create or change the schema. Here, the
predicate `name` is the name of an account. It's indexed so that we can look up
accounts based on their name.

```sh
$ curl -X POST localhost:8080/alter -d \
'name: string @index(term) .
type Person {
name
}'
```

If all goes well, the response should be `{"code":"Success","message":"Done"}`.

Other operations can be performed via the `/alter` endpoint as well. A specific
predicate or the entire database can be dropped.

To drop the predicate `name`:

```sh
$ curl -X POST localhost:8080/alter -d '{"drop_attr": "name"}'
```

To drop the type `Film`:
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_op": "TYPE", "drop_value": "Film"}'
```

To drop all data and schema:
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_all": true}'
```

To drop all data only (keep schema):
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'
```

## Start a transaction

Expand Down
73 changes: 73 additions & 0 deletions content/howto/drop-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
+++
date = ""
title = "Drop all data"
[menu.main]
parent = "howto"
+++


It is possible to drop all data from your Dgraph Cloud backend, and start afresh while retaining the same endpoint.

Be careful, as this operation is not reversible, and all data will be lost. It is highly recommended that you [export](/admin/import-export) your data before you drop your data.

### Dropping data from the Cloud UI
In order to drop all data while retaining the schema :
- access the [Schema](https://cloud.dgraph.io/_/schema) panel
- click the <kbd>Drop Data</kbd> button at the bottom of the schema.
- select the options and confirm.

*![Drop Data](/images/drop-data.png)*


### Dropping Data Programmatically

You can drop data by invoking the `dropData` mutation on `/admin/slash` endpoint.

As an example, if your GraphQL endpoint is `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/graphql`, then the admin endpoint for schema will be at `https://frozen-mango.us-west-2.aws.cloud.dgraph.io/admin/slash`.

This endpoint requires [Authentication](/admin/authentication).

Here is curl example.

```
curl 'https://<your-backend>/admin/slash' \
-H 'X-Auth-Token: <your-token>' \
-H 'Content-Type: application/graphql' \
--data-binary 'mutation { dropData(allData: true) { response { code message } } }'
```

If you would like to drop the schema along with the data, then you can set the `allDataAndSchema` flag.

```
curl 'https://<your-backend>/admin/slash' \
-H 'X-Auth-Token: <your-token>' \
-H 'Content-Type: application/graphql' \
--data-binary 'mutation { dropData(allDataAndSchema: true) { response { code message } } }'
```

## On-Premise
### Drop data and schema

The `/alter` endpoint is used to drop data.

To drop all data and schema:
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_all": true}'
```

To drop all data only (keep schema):
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'
```
The `/alter` endpoint can also be used to drop a specific property or all nodes of a specific type.

To drop property `name`:

```sh
$ curl -X POST localhost:8080/alter -d '{"drop_attr": "name"}'
```

To drop the type `Film`:
```sh
$ curl -X POST localhost:8080/alter -d '{"drop_op": "TYPE", "drop_value": "Film"}'
```
Binary file added static/images/drop-data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.