Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What package to use for database migrations in Go? [closed]

I am fairly new to golang, and trying to identify the best tools for the job. Currently I am evaluating the following packages:

https://github.com/mattes/migrate

https://github.com/DavidHuie/gomigrate

https://bitbucket.org/liamstask/goose/

I was wondering if anyone had any experience with these (or other packages) and could provide some comments.

like image 744
josephmisiti Avatar asked Nov 10 '15 03:11

josephmisiti


People also ask

How do you make migrations in go?

Create a new migrationStart with migrate create . Then the extension of the file will be sql , and the directory to store it is db/migration . We use the -seq flag to generate a sequential version number for the migration file. And finally the name of the migration, which is init_schema in this case.

How do I install migrate?

Step 1: Open the terminal for executing the installation commands. Step 2: Let us setup the repository to install the migrate package. Step 3: Update the system by executing the following command. Step 4: Now, it's time to set up golang migrate.


2 Answers

We use mattes/migrate at work and are very happy with it. It works with plain SQL files, handles file naming by itself and can easily be automated via CLI. It doesn't do anything Go specific.

With gomigrate you need to create the files yourself and write code for executing the migrations.

like image 165
Duru Can Celasun Avatar answered Oct 25 '22 13:10

Duru Can Celasun


Take a look at https://github.com/pressly/goose, a maintained fork of https://bitbucket.org/liamstask/goose/.

like image 30
Vojtech Vitek Avatar answered Oct 25 '22 15:10

Vojtech Vitek