Skip to main content

One post tagged with "database"

View All Tags

Database Migrations in Go with go-migrate

· 4 min read

Introduction

As applications evolve, database schemas change as well. You might need to add new tables, modify existing columns, or remove outdated ones. Managing these changes manually quickly becomes difficult, especially when multiple developers are working on the same project.

Database migration tools solve this problem by keeping track of schema changes and applying them in a predictable way. They also make it easy to roll back changes if something goes wrong.

In this article, we'll learn how to manage database migrations in Go using go-migrate. We'll install the CLI, create migration files, apply them to a PostgreSQL database, and roll them back.

Photo by Jan Antonin Kolar on Unsplash