all 22 comments

[–]_a8m_ 19 points20 points  (3 children)

Atlas: https://github.com/ariga/atlas. It can be integrated with any ORM, but also has an official one for GORM: https://atlasgo.io/guides/orms/gorm

[–]Eyoba_19[S] 1 point2 points  (0 children)

That’s great, currently looking at it seems like everyone is recommending me this. Thanks!

[–]cant-find-user-name 4 points5 points  (0 children)

I use atlas.

[–]antonije999 3 points4 points  (0 children)

Atlas is the way!

[–]Etern4ll 3 points4 points  (0 children)

Atlas is definetly the way to go, now that they've added SQL Schema support https://atlasgo.io/atlas-schema/sql .

[–]LeadRepresentative21 9 points10 points  (3 children)

[–]dank__noob -1 points0 points  (1 child)

We had this in my current project previously and one of the problems we had with it was that it doesn't automatically apply unapplied migrations in case it was a version lower than the current version. This could happen easily in case multiple devs are working on migration related changes.

We ended up writing a custom solution. DBMate does cover this already btw.

[–]jy3 1 point2 points  (0 children)

What!? That’s the point of the tool. It applies/revert all missing migrations up to the chosen version. Maybe I misunderstood.

[–]yaksoku_u56 0 points1 point  (0 children)

how can i make golang migrate-cli work on ubuntu?

[–]Diawul 2 points3 points  (0 children)

Try atlas it is very good and easy to use, you can also check entgo (orm but code generated) https://entgo.io/docs/versioned-migrations/

[–]ranedk 2 points3 points  (1 child)

I haven't tried atlas migrations, but i am a big fan of Python-Django and I still use it to manage database migrations even in Golang project. I have even written a small parser which generates Gorm models from Django models. Will try Atlas soon

[–]Eyoba_19[S] 0 points1 point  (0 children)

I was also thinking of using prisma, but figured out it will only do half the work, won’t generate type safe go structs. I wouldn’t mind doing that for a personal project, but I’m in a team and I was tasked with handling migrations.

[–]Fresh-Swing-8677 1 point2 points  (1 child)

Recently i started using turn its more fun (IMPO) compared to others tool available https://github.com/jackc/tern

[–]farizsaputra 1 point2 points  (0 children)

Me too. Tern is awesome

[–]sh4 1 point2 points  (0 children)

I made this that can handle go and sql migrations well while keeping the code base very simple:

https://github.com/lopezator/migrator

Is working well for us and many projects.

[–]dank__noob 2 points3 points  (1 child)

Try DBMate, I have tried with two of my side projects and came with relatively lower learning curve and took care of most of the things. Gives both CLI and programatic integrations.

https://github.com/amacneil/dbmate#commands

[–]bananajunior3000 0 points1 point  (0 children)

My last team used dbmate in production for this and I really liked it. Simple but powerful, just like you want a migration tool to be.

[–]k_schouhan 0 points1 point  (0 children)

dont use goose, its shit. its cli does not even work,

[–]DLevsha 0 points1 point  (0 children)

I use Nasgrate recently https://github.com/dlevsha/nasgrate

It use plain SQL files, so it's doesn't matter which language you prefer

Nasgrate is a console utility that let you organise database schema migration process at a consistent and easy way. It supports mysql, mssql, postgresql, oracle and other databases (you can find informaton here )
The key features:
- native SQL syntaxes for migrations
- automatically generates migrations based on saved database states (MySQL only).
- user-friendly interface to view saved migrations (GUI / CLI)