Skip to content
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

trs/wip/json-schema #243

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

trs/wip/json-schema #243

wants to merge 2 commits into from

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Jul 23, 2021

Example of using JSON Schema to validate or partially validate/constrain some of our document or details columns. Outdated due to early format for receiving.presence_absence that was never used, but usage of JSON Schema in the database maybe useful to think about again as the API surface increases.

Vendors <https://github.com/gavinwahl/postgres-json-schema> by
unbundling the extension into a vanilla function.

Since we intend to stay compatible with cloud database providers (Azure,
AWS), we can't install custom Pg extensions.  Luckily, this JSON Schema
extension is written in PL/pgSQL and under an MIT-style license, which
means we can vendor the definitions very easily ourselves.

I tweaked the functions to mark them parallel-safe and to return null
(instead of true!) when given a null JSON document to validate.
Light validation to ensure consistent high-level structure while leaving
the identifiers for source and target material up to convention.

JSON Schema validation happens in the database itself, following the
principle of making the database the ultimate authority on data
integrity and validation.
@tsibley tsibley changed the title trs/wip/json schema trs/wip/json-schema Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant