From 456a1477271a9f9bd3484f842e7f400d97699f54 Mon Sep 17 00:00:00 2001 From: Philippe Gaultier Date: Thu, 30 Oct 2025 10:31:10 +0100 Subject: [PATCH] chore: add migration tests in kratos non-oss for crdb GitOrigin-RevId: d94d8a0ac9c722c665caff84a971d8b247f5f340 --- oryx/popx/migration_box.go | 3 ++- oryx/popx/migrator.go | 12 +++++++----- oryx/randx/strength/go.sum | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/oryx/popx/migration_box.go b/oryx/popx/migration_box.go index cfd1cf2940d6..77d6fa91b4ba 100644 --- a/oryx/popx/migration_box.go +++ b/oryx/popx/migration_box.go @@ -91,7 +91,8 @@ func WithTestdata(t *testing.T, testdata fs.FS) MigrationBoxOption { if err != nil { return err } - if info.IsDir() { + if !info.Type().IsRegular() { + t.Logf("skipping testdata entry that is not a file: %s", path) return nil } diff --git a/oryx/popx/migrator.go b/oryx/popx/migrator.go index f93490bca8c3..346742560b9e 100644 --- a/oryx/popx/migrator.go +++ b/oryx/popx/migrator.go @@ -164,7 +164,8 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) { reverted := 0 defer func() { - mb.l.Debugf("Successfully reverted %d migrations.", reverted) + migrationsToRevertCount := min(steps, len(mfs)) + mb.l.Debugf("Successfully reverted %d/%d migrations.", reverted, migrationsToRevertCount) if err != nil { mb.l.WithError(err).Error("Problem reverting migrations.") } @@ -174,6 +175,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) { break } l := mb.l.WithField("version", mi.Version).WithField("migration_name", mi.Name).WithField("migration_file", mi.Path) + l.Debugf("handling migration %s", mi.Name) exists, err := c.Where("version = ?", mi.Version).Exists(mtn) if err != nil { return errors.Wrapf(err, "problem checking for migration version %s", mi.Version) @@ -194,7 +196,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) { } if err := mi.Valid(); err != nil { - return err + return errors.WithStack(err) } if mb.shouldNotUseTransaction(mi) { @@ -211,7 +213,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) { if err := mb.isolatedTransaction(ctx, "down", func(conn *pop.Connection) error { err := mi.Runner(mi, conn) if err != nil { - return err + return errors.WithStack(err) } // #nosec G201 - mtn is a system-wide const @@ -221,11 +223,11 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) { return nil }); err != nil { - return err + return errors.WithStack(err) } } - l.Infof("< %s applied successfully", mi.Name) + l.Infof("%s applied successfully", mi.Name) reverted++ } return nil diff --git a/oryx/randx/strength/go.sum b/oryx/randx/strength/go.sum index 41365e142719..af5ed80fcbb6 100644 --- a/oryx/randx/strength/go.sum +++ b/oryx/randx/strength/go.sum @@ -27,8 +27,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=