How do I delete schemas from Snowplow Mini?


#1

How do I delete schemas from snowplow mini? I was working with some old schemas that aren’t correct and would like to clear everything out so I can start fresh with my new schemas. It doesn’t look like the iglu server supports delete (at least as listed on the maintenance page).


#2

Hello @dcow,

You need to use curl for that.

First, create API key with write access:

curl -POST "http://your-snowplow-mini:8081/api/auth/keygen" -H "apikey: master-key-uuid" -d "vendor_prefix=*"

In above, replace your-snowplow-mini with host and master-key-uuid with your actual master key. This additional step required because master key (which you should have since install) is key which you can use only to create/delete other API keys and but schemas. This should output a JSON like following:

{
  "read" : "3eb8af77-7f95-4fde-9643-98d510ce64eb",
  "write" : "40974eeb-9fbc-4024-a2bf-0ec22bccad24"
}

Now you can use write API key to delete your schema using following command:

curl -XDELETE http://your-snowplow-mini:8081/api/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0 -H "apikey: 40974eeb-9fbc-4024-a2bf-0ec22bccad24"

Just replace placeholders for host, schema URI and write apikey with your actual data.

Hope that help,
Anton


#3

@dcow,

Also, you can just upload your new schemas, using PUT method (that is how iglu_server_upload.sh script works). Schemas with same URI will be just silently overridden.


#4

@anton thanks. Can I also just drop the schemas table (and accompanying sequence) and restart the server?


#5

@dcow, yes that should work, I guess: it will simply reinitialize table. Anyway, it’s better to not drop table, but delete all entities - then you even won’t need to restart a server:

psql --host localhost -U snowplow -W iglu  # password: snowplow

and

DELETE FROM schemas;

#6

@anton I still had to restart the server because dropping everything from the schemas table also removes the cached self-desc schema so uploading future schemas fails.