From 818266e199f0f7fd18b39d943245b49718b82377 Mon Sep 17 00:00:00 2001 From: Alexis Viscogliosi Date: Thu, 31 Oct 2024 10:58:37 +0100 Subject: [PATCH] fix: status --- pkg/amigo/amigo.go | 2 +- pkg/templates/migrations.go.tmpl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/amigo/amigo.go b/pkg/amigo/amigo.go index 2de75be..3f88e7c 100644 --- a/pkg/amigo/amigo.go +++ b/pkg/amigo/amigo.go @@ -219,7 +219,7 @@ func (a Amigo) GenerateMigrationsFiles(writer io.Writer) error { // GetStatus return the state of the database func (a Amigo) GetStatus(db *sql.DB) ([]string, error) { - rows, err := db.Query("SELECT id FROM " + a.ctx.SchemaVersionTable + " ORDER BY id desc") + rows, err := db.Query("SELECT version FROM " + a.ctx.SchemaVersionTable + " ORDER BY version desc") if err != nil { return nil, fmt.Errorf("unable to get state: %w", err) } diff --git a/pkg/templates/migrations.go.tmpl b/pkg/templates/migrations.go.tmpl index 4e02a5e..26ecff1 100644 --- a/pkg/templates/migrations.go.tmpl +++ b/pkg/templates/migrations.go.tmpl @@ -7,9 +7,10 @@ import ( "embed" {{if .ImportSchemaPackage}}"{{ .ImportSchemaPackage }}"{{end}} ) - +{{if .ImportSchemaPackage}} //go:embed *.sql var sqlMigrationsFS embed.FS +{{end}} var Migrations = []schema.Migration{ {{- range .Migrations }}