From a4de30ecb77a03bf78f2f6624b8b125495fadcb4 Mon Sep 17 00:00:00 2001 From: Michael Fridman Date: Sun, 12 May 2024 07:27:53 -0400 Subject: [PATCH] fix: improve error message in missing migrations (#772) --- Makefile | 3 +++ up.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8b859f4bc..e68eff0b7 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,7 @@ docker-postgres: -p $(DB_POSTGRES_PORT):5432 \ -l goose_test \ postgres:14-alpine -c log_statement=all + echo "postgres://$(DB_USER):$(DB_PASSWORD)@localhost:$(DB_POSTGRES_PORT)/$(DB_NAME)?sslmode=disable" docker-mysql: docker run --rm -d \ @@ -112,6 +113,7 @@ docker-mysql: -p $(DB_MYSQL_PORT):3306 \ -l goose_test \ mysql:8.0.31 + echo "mysql://$(DB_USER):$(DB_PASSWORD)@localhost:$(DB_MYSQL_PORT)/$(DB_NAME)?parseTime=true" docker-clickhouse: docker run --rm -d \ @@ -122,6 +124,7 @@ docker-clickhouse: -p $(DB_CLICKHOUSE_PORT):9000/tcp \ -l goose_test \ clickhouse/clickhouse-server:23-alpine + echo "clickhouse://$(DB_USER):$(DB_PASSWORD)@localhost:$(DB_CLICKHOUSE_PORT)/$(DB_NAME)" docker-turso: docker run --rm -d \ diff --git a/up.go b/up.go index 4f75620dd..d90789352 100644 --- a/up.go +++ b/up.go @@ -85,8 +85,8 @@ func UpToContext(ctx context.Context, db *sql.DB, dir string, version int64, opt output := fmt.Sprintf("version %d: %s", m.Version, m.Source) collected = append(collected, output) } - return fmt.Errorf("error: found %d missing migrations:\n\t%s", - len(missingMigrations), strings.Join(collected, "\n\t")) + return fmt.Errorf("error: found %d missing migrations before current version %d:\n\t%s", + len(missingMigrations), dbMaxVersion, strings.Join(collected, "\n\t")) } var migrationsToApply Migrations if option.allowMissing {