Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save klaussilveira/229c3799d3943c08b801038316c4d61d to your computer and use it in GitHub Desktop.
Save klaussilveira/229c3799d3943c08b801038316c4d61d to your computer and use it in GitHub Desktop.
alter table books
add constraint books_doc_isbn_ok
check(
doc->>'ISBN' is not null and
jsonb_typeof(doc->'ISBN') = 'number' and
(doc->>'ISBN')::bigint > 0 and
length(doc->>'ISBN') = 13
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment