Installing Golang Migrate

Let’s install Golang Migrate now, but before that, make sure that you have GO installed on your PC. Check if you had GO installed on your PC. Run the following command in cmd to check that:

$ go version

 

If that shows an error or the go command is not recognized as internal or external, it means you don’t have GO installed on your PC. Also, if your version of GO is less than 1.15, follow this GFG article and install the latest version of GO: Install GO. Let’s start the process of installing GOLANG MIGRATE now,

Method 1: (Using Scoop)

Scoop is A command-line installer for Windows; this makes the installation of programs easy and fast. If you had installed it early, then jump to step 2. Else, don’t worry, it’s just 1 step process,

Step 1: Install Scoop: Open the Windows power shell on your PC, and run the following command to install SCOOP.

$ irm get.scoop.sh | iex

 

This shows that Scoop is installed successfully on your PC.

Step 2: Install Migrate: Open the Windows power shell on your PC, and run the following command to install MIGRATE.

$ scoop install migrate

 

Now you are all set to use MIGRATE for your database migrations.

Method 2: (Using Go Toolchain)

If you have git installed already on your PC, then proceed to Step 2. Else, follow the process in Step 1.

Step 1: Install GIT: If you don’t have git installed but Scoop installed on your PC, proceed to Step 1.2 or else follow Step 1.1.

  • Install Scoop first following Method 1, Step 1.
  • Open Windows PowerShell, using the following command to install git.

$ scoop install git

 

Step 2: Open Windows Powershell and run the following commands,

$ go get -u -d github.com/golang-migrate/migrate/cmd/migrate

While running the below command, go through your PC, find the path where it is located and run the command. It may be in a different drive or directory, so carefully check all possible directories with names related to GO. You can see the example from my commands. Use the ls command wherever it is necessary.

$ cd src/github.com/golang-migrate/migrate/cmd/migrate

 

 Step 3: After running the above commands, run the following commands,

$ git checkout v4.15.2

We are using v4.15.2 here because it is the latest version.

$ go install

Check by running,

$ migrate -version

It should give output as v4.15.2.

 

Now you are all set to use MIGRATE for your database migrations.


How to Install Golang Migrate on Windows?

Golang (also called Go language) is an open-source procedural language. It is designed by Robert Griesemer, Rob Pike, and Ken Thompson at Google. It was developed in 2007 and publicly announced in 2009. Golang is widely used in Google and many other open-source projects. Have a look at this article for more information about Golang Programming Language.

Similar Reads

Golang Migrate

Golang Migrate is a Golang package that is used for handling database migrations. Golang database migrations are imported as libraries or used as CLI. Golang migrates reads migrations from the sources like (Filesystem, io/fs, GitHub, Google cloud storage, etc…) and applies them to the databases like (PGX, Redshift, MongoDB, MySQL, etc…). Databases don’t have self-thinking capacities as humans. If it’s incomplete or incorrect, it fails....

Installing Golang Migrate

Let’s install Golang Migrate now, but before that, make sure that you have GO installed on your PC. Check if you had GO installed on your PC. Run the following command in cmd to check that:...

Contact Us