@@ -4,9 +4,7 @@ package cmd
4
4
5
5
import (
6
6
"fmt"
7
- "os"
8
7
"path/filepath"
9
- "slices"
10
8
11
9
"github.com/spf13/cobra"
12
10
)
@@ -27,22 +25,14 @@ in lexicographical order. All migrations are completed.`,
27
25
defer m .Close ()
28
26
29
27
// open folder and read all json files
30
- files , err := os . ReadDir ( migrationsDir )
28
+ files , err := filepath . Glob ( filepath . Join ( migrationsDir , "*.json" ) )
31
29
if err != nil {
32
30
return fmt .Errorf ("reading migration directory: %w" , err )
33
31
}
34
- migrationFiles := []string {}
35
- for _ , file := range files {
36
- if file .IsDir () || filepath .Ext (file .Name ()) != ".json" {
37
- continue
38
- }
39
- migrationFiles = append (migrationFiles , filepath .Join (migrationsDir , file .Name ()))
40
- }
41
- slices .Sort (migrationFiles )
42
32
43
- for _ , fileName := range migrationFiles {
44
- if err := runMigrationFromFile (cmd .Context (), m , fileName , true ); err != nil {
45
- return fmt .Errorf ("running migration file '%s' : %w" , fileName , err )
33
+ for _ , file := range files {
34
+ if err := runMigrationFromFile (cmd .Context (), m , file , true ); err != nil {
35
+ return fmt .Errorf ("running migration file %q : %w" , file , err )
46
36
}
47
37
}
48
38
0 commit comments