Drop all data from Dgraph

We can drop all data from Dgraph via Post curl request.

A. To drop all data and schema:

$ curl -X POST localhost:8080/alter -d ‘{“drop_all”: true}’

B. To drop all data only (keep schema):

$ curl -X POST localhost:8080/alter -d ‘{“drop_op”: “DATA”}’

  1. How I can drop all data via Ratel UI?
    A. Schema->BulkEdit->Drop All (Drop All data with schema)
    B. ? (Drop All data without schema) ? Is it possible?
  2. How I can do this via url endpoint?
    localhost:8080/alter - does not work
    A. ? (Drop All data with schema)
    B. ? (Drop All data without schema)
1 Like

Hi vladimir ! , if you want to drop all data from via Ratel UI you can go to Schema->BulkEdit->Drop All :wink:

1 Like

It’s work, but:

How I can drop all data via Ratel UI?

B. ? (Drop All data without schema) ? Is it possible?
How I can do this via url endpoint?
localhost:8080/alter - does not work

A. ? (Drop All data with schema)
B. ? (Drop All data without schema)

No, you can open a request in Ratel’s repo tho.

Not sure if it works via HTTP queries.

But
curl -X POST localhost:8080/alter -d ‘{“drop_op”: “DATA”}’
is post request or not?
And mutate is post request?
https://docs.dgraph.io/deploy/#delete-database
To drop all data, you could send a DropAll request via /alter endpoint.

Not sure what you mean. You’ve asked about doing this in Ratel. It can’t. The drop all func in bulk edit is a built-in thing. It just does “drop all” not “drop data”.

And you’ve asked about doing via URL endpoint. What exactly it means? via browser? via curl?
If it is via browser I think it can’t be done. If it is via curl, it should work as you described.

https://docs.dgraph.io/deploy/#delete-database
To drop all data, you could send a DropAll request via /alter endpoint.

I mean via the browser. I think the topic above about get request with endpoint via browser string or not?

This doesn’t work

http://localhost:8080/alter?drop_all=true

Yes, it doesn’t work :cold_sweat:
printscreen

The way to do the drop data operation over HTTP is via the POST request:

curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'

We can add a way to do that in Ratel too. I’ve created a feature request:

https://github.com/dgraph-io/ratel/issues/159

4 Likes

Nope. Doesn’t work…
curl -X POST localhost:8080/alter -d ‘{“drop_op”: “DATA”}’
{“errors”:[{“message”:“while lexing '{drop_op: at line 1 column 0: Invalid schema. Unexpected '”,“extensions”:{“code”:“Error”}}]}curl: (3) [globbing] unmatched close brace/bracket in column 5

Hey @onkarbanerjee, please note to use correct " and '. Yours are quite different “ and ‘, therefore unrecognized by lexer.

Can you try retyping the command in case you are copy pasting it? Because if I try running

I get the same error. But if I rerun the command by typing I get the desired results.

After upgrading to the lastest version of standalone:master my tests are now failing.

 query:
            {"drop_op": "DATA"}graphql error:
            while lexing {"drop_op": "DATA"} at line 1 column 1: Invalid schema. Unexpected "

This code was working

query := strings.NewReader(`{"drop_op": "DATA"}`)

Raw Message:

*****graphql*******>
 {"drop_op": "DATA"}
 {"errors":[{"message":"while lexing {\"drop_op\": \"DATA\"} at line 1 column 1: Invalid schema. Unexpected \"","extensions":{"code":"Error"}}]}

Any thoughts?

With dgo it should be like

op := api.Operation{drop_op: "DATA"}

Thanks for the response. I am making a raw graphql call over HTTP and this was working until I downloaded the latest version of master :frowning:

weird, cuz nothing was changed in that matter. Also I have tested locally and

curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'

is working fine.

BTW, in the future, all HTTP calls might be deprecated. It seems that all of them will be at the GraphQL admin.

I am making this call using /alter and I need this to exist for running tests.

dgraph/standalone master 69d0f682a33c 39 hours ago 166MB

Have you tried a manual cURL?