New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a way to compare schemas that is formatting agnostic #1804
Comments
@theronic https://github.com/authzed/spicedb/tree/main/pkg/diff has a diff package which can be used after parsing the schema SpiceDB always returns the normalized, ordered schema and that won't be changing; we don't store the actual text |
Thanks @josephschorr, but my application is not written in Golang. Can |
@theronic What, exactly, are you trying to do? What is your intention around if the schema has changed? |
I'm trying to compare if the schema in prod SpiceDB instance differs from the Spice schema I have on-disk, e.g. when deploying a new version of app. At this stage, just convenient to check that I know I'm querying the right schema. I guess I'll need schema migrations anyway 🤔 |
We could look into adding a SchemaDiff API, but you could just also call WriteSchema; if there are no changes, it'll no-op |
Thanks. How do you keep track of Spice schema versioning? Practical example similar to mismatched database schema: given a set of schema migrations, prod might think it has v3 of Spice Schema, but since schema is stateful, a different schema could have been written to Spice, so I'd like to ensure that the current production schema matches the previous migration that was run before running additional migrations. |
We have our database migrations also call WriteSchema, so they move in sync |
We should look into exporting the diff library via the API |
Thanks. How do you keep track of which schema version was written to Spice? External hash / commit / version number in DB? Would be nice if SchemaService took a DiffSchemaRequest and returned whatever the diff pkg would return. |
Yep
Yeah, I updated the issue for that and reopened it |
Is there a BNF syntax spec somewhere for the Schema language in the meantime so I can parse the schema text and compare the sorted parse tree? |
No. The implementation is considered the spec |
Problem Statement
If you call
.readSchema
after calling.writeSchema
(via GRPC), Spice returns a schema string with reordered definitions that does not match the string that was written. I want to compare if my schema is up-to-date without writing a parser for the SpiceDB schema language.Solution Brainstorm
Return the same schema text string that was written via
.writeSchema
.Alternatively, is there a "compareSchema" function somewhere?
The text was updated successfully, but these errors were encountered: