Checking the migration status with golang-migrate

If you're using golang-migrate to perform your database migrations, you may wonder how to check what the current state of your migrations is.

I recently found myself doing the same, but finding an absence of anything explicitly documenting this, so thought I'd write it as a form of blogumentation.

When running the version subcommand:

# for migrate v4.15.2
migrate -database "$DATABASE_URL" -path db/migrations version

We then receive the timestamp of the current migration state.

For instance, if we have the two migrations:

1481574547_create_users_table.up.sql
1481840000_alter_users_table.up.sql

The version subcommand reporting a 1481574547 would indicate that we have not yet applied 1481840000_alter_users_table.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #go #sql.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.