Skip to content

Commit 186a2cb

Browse files
committed
[REF] requested changes
1 parent 8e9fa2d commit 186a2cb

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

cmd/migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func init() {
152152
migrationCmd.AddCommand(migrationFetchCmd)
153153
// Build new command
154154
newFlags := migrationNewCmd.Flags()
155-
newFlags.BoolVarP(&repeatable, "repeatable", "r", false, "Creates a repeatable migration instead of a common migration.")
155+
newFlags.BoolVarP(&repeatable, "repeatable", "r", false, "Creates a repeatable migration instead of a versioned migration.")
156156
migrationCmd.AddCommand(migrationNewCmd)
157157
rootCmd.AddCommand(migrationCmd)
158158
}

internal/migration/new/new.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func Run(repeatable bool, migrationName string, stdin afero.File, fsys afero.Fs) error {
15-
path := ""
15+
var path string
1616

1717
if repeatable {
1818
// if migration name already exists, repeatable migration will be overwritten

internal/migration/up/up.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@ func Run(ctx context.Context, includeAll bool, config pgconn.Config, fsys afero.
2424
return err
2525
}
2626

27-
err = migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys))
28-
if err != nil {
29-
return err
30-
}
31-
32-
repeatableMigrations, err := migration.ListRepeatableMigrations(utils.MigrationsDir, afero.NewIOFS(fsys))
33-
if err != nil {
34-
return err
35-
}
36-
37-
return migration.ApplyMigrations(ctx, repeatableMigrations, conn, afero.NewIOFS(fsys))
27+
return migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys))
3828
}
3929

4030
func GetPendingMigrations(ctx context.Context, includeAll bool, conn *pgx.Conn, fsys afero.Fs) ([]string, error) {
@@ -56,6 +46,11 @@ func GetPendingMigrations(ctx context.Context, includeAll bool, conn *pgx.Conn,
5646
}
5747
utils.CmdSuggestion = suggestIgnoreFlag(diff)
5848
}
49+
repeatableMigrations, err := migration.ListRepeatableMigrations(utils.MigrationsDir, afero.NewIOFS(fsys))
50+
if err != nil {
51+
return nil, err
52+
}
53+
diff = append(diff, repeatableMigrations...)
5954
return diff, err
6055
}
6156

0 commit comments

Comments
 (0)