schema versioning
# spicedb
a
Hi, I want to set up versioning for the schema so that we can see which version of the schema is currently in the repository and which is in production or testing, etc. Initially, I thought about using revisions, but then realized that revisions apply to the whole system. I need to be able to see exactly which version of a particular schema is installed on the system. Does anybody solved this problem before or can suggest a solution?
v
You can add metadata in the form of a comment in the schema:
Copy code
% zed schema read
// version: 1
definition resource {
    relation reader: user
    relation writer: user
    permission read = reader + writer
    permission write = writer
}

definition user {}
we've discussed using staging schemas for the future too, so that it makes rolling out changes and rolling back a fully supported operation
a
Ok, thank you
v
If you use Go, I believe you can use the schema compiler package, and retrieve the documentation associated with a type, so you don't have to implement your own parsing
we are also working on a new schema reflection API that would allow you to retrieve comments from a type or relation: https://github.com/authzed/api/pull/98 so you could define an unused type like
definition internal_metadata{}
and add all that version tracking information as a comment there, and retrieve it programatically
a
That's greate, thank you)
Am I right that it is only changes in proto files and it is not implemented in spicedb client yet, yes?
v
yes, no implemented just yet. There is also a schema diff API.
a
ok, thank you
5 Views