~samwhited/migration

31b32c7122314040986b7e0699e37ee1e429a200 — Sam Whited 3 months ago 4ae757a master v0.0.5
migration: fix walking migrations tree
1 files changed, 14 insertions(+), 16 deletions(-)

M migration.go
M migration.go => migration.go +14 -16
@@ 10,7 10,6 @@ import (
	"io/fs"
	"os"
	"path"
	"sort"
	"strings"
	"time"



@@ 169,22 168,21 @@ func NewWalker(ctx context.Context, migrationsTable string, tx *sql.Tx) (Walker,
	}

	return func(vfs fs.FS, f WalkFunc) error {
		files, err := fs.ReadDir(vfs, ".")
		if err != nil {
			return err
		}
		sort.Slice(files, func(i, j int) bool {
			return files[i].Name() < files[j].Name()
		})

		for _, info := range files {
		err := fs.WalkDir(vfs, ".", func(p string, info fs.DirEntry, err error) error {
			if p == "." {
				return nil
			}
			if err != nil {
				return err
			}
			if !info.IsDir() {
				continue
				return nil
			}

			name := info.Name()
			idx := strings.Index(name, "_")
			if idx == -1 {
				continue
				return nil
			}
			name = strings.Replace(name[:idx], "-", "", -1)
			var status RunStatus


@@ 200,10 198,10 @@ func NewWalker(ctx context.Context, migrationsTable string, tx *sql.Tx) (Walker,
					status = StatusNotRun
				}
			}
			err = f(name, info, status)
			if err != nil {
				return err
			}
			return f(name, info, status)
		})
		if err != nil {
			return err
		}

		for _, missing := range ran {