How to manage database schemas

97 views
Skip to first unread message

Bhavesh Kothari

unread,
Dec 22, 2024, 8:45:23 AM (6 days ago) Dec 22
to golang-nuts
Hello everyone,
I'm new to go and have to work on a project from scratch.
I looked into for various resources and learnt golang, also selected gin as my project framework and pgx as my post-gres driver.

Now I'm looking out for guidance on how I can manage my database schemas for this project.
I know about ORMs but go community avoid them.
I heard about SQLc a lot, but my question is how can I use it to manage my database schemas with it, is it event possible? Like If I add new column in database or rename one how will it get synced to in codebase and will I have to update all of my queries manually?
Also, I found that when I run raw queries my JSON columns come as some weird hash, what am I missing here?

If possible, I would be more than happy if I can connect with someone who is into golang for years and can provide expert advice over teams or meet call.

Thank You.

Igor Cananea

unread,
Dec 22, 2024, 8:51:02 AM (6 days ago) Dec 22
to Bhavesh Kothari, golang-nuts

There are a couple of good options for schema management  in Go. Personally, I use goose with sqlc but you can use it with ORMs too.


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/60004d92-ecd0-41df-94f6-2b07464a3e2en%40googlegroups.com.

Brian Candler

unread,
Dec 22, 2024, 9:35:15 AM (6 days ago) Dec 22
to golang-nuts
> I heard about SQLc a lot, but my question is how can I use it to manage my database schemas with it, is it event possible?

sqlc works with a bunch of different migration tools:

The one called "tern" is postgres-specific but from the same person who wrote pgx

> Also, I found that when I run raw queries my JSON columns come as some weird hash, what am I missing here?

Can you give an example?
Reply all
Reply to author
Forward
0 new messages