diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..66544f01 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 9ccd0c7f..2ae05f81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /public .idea .DS_Store +.hugo_build.lock diff --git a/content/clients/raw-http.md b/content/clients/raw-http.md index 9c401afd..c143d940 100644 --- a/content/clients/raw-http.md +++ b/content/clients/raw-http.md @@ -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 diff --git a/content/howto/drop-data.md b/content/howto/drop-data.md new file mode 100644 index 00000000..4e5fc44e --- /dev/null +++ b/content/howto/drop-data.md @@ -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 Drop Data 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:///admin/slash' \ + -H 'X-Auth-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:///admin/slash' \ + -H 'X-Auth-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"}' +``` diff --git a/static/images/drop-data.png b/static/images/drop-data.png new file mode 100644 index 00000000..2a0258c3 Binary files /dev/null and b/static/images/drop-data.png differ