protorm: generate GORM (and SQL/Prisma) schemas from protobuf + AIP annotations

7 views
Skip to first unread message

Srikanth Kandarp

unread,
9:27 AM (2 hours ago) 9:27 AM
to grpc.io
Been building proto-first for a while and got tired of keeping my DB schema in
sync with my protobuf messages by hand. So I wrote a protoc plugin that derives
the schema from the AIP annotations already on the messages
(google.api.resource, field_behavior, resource_reference) and emits GORM
structs, Postgres DDL, Prisma, or a CSV manifest — all from a single IR, so
they can't disagree.

Go-relevant bits: GORM output is one package per schema, pointer types for
nullable columns, relation fields wired from resource_reference. Built with
buf, Apache-2.0.

Design call I went back and forth on and want opinions on: nullable columns map
to pointer types (*string). Honest about NULL, but pointers everywhere are a
pain to work with. Alternative is sql.Null* or non-pointer + a separate
nullability signal. What would you actually want generated?

v0.1 / early. https://github.com/oh-tarnished/protorm
Reply all
Reply to author
Forward
0 new messages