3 ms·
How do you do migrations with Golang? Which ORM do you use?
by xstartup 9y ago
How do you do migrations with Golang? Which ORM do you use?
- abdelm 9y agoThis may be useful: https://github.com/mattes/migrate https://github.com/mattes/migrate
- majewsky 9y agoSeconded. 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/ab4245a8f195672b808f990f9f7c2452652c475d/main.go#L145-L178 https://github.com/sapcc/limes/blob/ab4245a8f195672b808f990f...
- zuzuleinen 9y agoFor ORM we use GORM: http://gorm.io http://gorm.io For migrations we use goose: https://github.com/pressly/goose https://github.com/pressly/goose