Skip to content

Commit 7330318

Browse files
fix: run ordering separately
1 parent f724bb5 commit 7330318

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

migration_runners.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ func NewFileMigrationRunner(paths []string, orderingFunc func([]string) []string
4141
func (r *FileMigrationRunner) RunMigrations(ctx context.Context, conn DatabaseConnection) error {
4242
var allFiles []string
4343

44-
// Collect all SQL files from all paths.
44+
// Collect and order files from each path separately.
4545
for _, path := range r.migrationPaths {
4646
files, err := r.collectSQLFiles(path)
4747
if err != nil {
4848
return fmt.Errorf("failed to collect files from %s: %w", path, err)
4949
}
50-
allFiles = append(allFiles, files...)
51-
}
5250

53-
// Order files (function always set).
54-
allFiles = r.orderingFunc(allFiles)
51+
// Order files within this directory.
52+
if len(files) > 0 {
53+
files = r.orderingFunc(files)
54+
allFiles = append(allFiles, files...)
55+
}
56+
}
5557

5658
// Execute each file.
5759
for _, file := range allFiles {

0 commit comments

Comments
 (0)