Hacker News new | past | comments | ask | show | jobs | submit login

How do you do migrations with Golang? Which ORM do you use?



For ORM we use GORM: http://gorm.io

For migrations we use goose: https://github.com/pressly/goose


This may be useful: https://github.com/mattes/migrate


Seconded. I use it with the go-bindata backend and Postgres driver. Some notes:

- Migrations are written in plain SQL, so there may be portability issues if you need to support multiple DBs. (Or you need to write the same migration once per supported SQL dialect.)

- It does not `CREATE DATABASE` for you when applying the first migration. For my app that uses Postgres, I wrote some extra code to do that. Feel free to copy if you like: https://github.com/sapcc/limes/blob/ab4245a8f195672b808f990f...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: