Hello, Any view how to delete the Spiceb schema vi...
# spicedb
r
Hello, Any view how to delete the Spiceb schema via rest api or cli ? I am using PostgreSQL and had a specific schema loaded. I wish to delete the same and push a new one which seems to fail. Don't see delete API nor via zed cli any option to delete ? Any view ?
v
👋🏻 there is no delete operation because the write schema API method replaces the entirety of the schema stored. If you are hitting an error is because you have relationships stored, so you'll need to first delete relationships and then write the new schema
this is a mechanism to prevent unitended data loss. SpiceDB checks what
definition
are deleted on your WriteSchema call, and checks if there are any relationships associated with any of the `relation`s in that
definition
r
Thanks
I deleted all required relation which were based on say xyz schema , now via rest api I am able to write new schema and 200 response , but now if I try to read the schema neither I see old xyz schema nor the new one ? and error says no schema defined with 404 error code
Copy code
{
  "code": 5,
  "message": "No schema has been defined; please call WriteSchema to start",
  "details": []
}
@vroldanbet @Joey
v
are you using the same prefix as before or a different one?
r
Do you mean namespace ? Yes I am using different namespace, I was under assumption that if all existing schema specific relation are deleted then we can update the existing schema and add more definition which could be under different namespace
v
Yeah no, I believe you have to use the same namespace prefix
Think the prefix as your tenant identifier. Everything you write has to have that prefix.
r
Let me share an example, If I use rest api to write following schema [v1/schema/write] and fetch the same via read [v1/schema/read] it fails But if same schema is pushed via Python script and then read via rest read api , it works .
Copy code
curl --location --request POST 'http://localhost:8443/v1/schema/write' \
--header 'Authorization: Bearer graphToken' \
--header 'Content-Type: application/json' \
--data-raw '{
    "schemaText": "definition authznamespace/namespace {}\n\ndefinition authznamespace/user {}"
}'
Any reason why write of above schema via rest api is not working ? [Note, rest api response is 200 ] @vroldanbet
j
@romil it probably wants
schema_text
actually, its
schema
r
Just tried that as well and it didnt work , still returns 200 but then the read is not returning same schema . Also the swagger api says it has to be
schemaText
read schema is
schemaText
write schema is
schema
r
ah that worked !! thanks for correcting
j
the reason it didn't give an error is that an empty schema is valid; its just ignored
r
yeah, thought so