@@ -164,7 +164,8 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
164164
165165 reverted := 0
166166 defer func () {
167- mb .l .Debugf ("Successfully reverted %d migrations." , reverted )
167+ migrationsToRevertCount := min (steps , len (mfs ))
168+ mb .l .Debugf ("Successfully reverted %d/%d migrations." , reverted , migrationsToRevertCount )
168169 if err != nil {
169170 mb .l .WithError (err ).Error ("Problem reverting migrations." )
170171 }
@@ -174,6 +175,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
174175 break
175176 }
176177 l := mb .l .WithField ("version" , mi .Version ).WithField ("migration_name" , mi .Name ).WithField ("migration_file" , mi .Path )
178+ l .Debugf ("handling migration %s" , mi .Name )
177179 exists , err := c .Where ("version = ?" , mi .Version ).Exists (mtn )
178180 if err != nil {
179181 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) {
194196 }
195197
196198 if err := mi .Valid (); err != nil {
197- return err
199+ return errors . WithStack ( err )
198200 }
199201
200202 if mb .shouldNotUseTransaction (mi ) {
@@ -211,7 +213,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
211213 if err := mb .isolatedTransaction (ctx , "down" , func (conn * pop.Connection ) error {
212214 err := mi .Runner (mi , conn )
213215 if err != nil {
214- return err
216+ return errors . WithStack ( err )
215217 }
216218
217219 // #nosec G201 - mtn is a system-wide const
@@ -221,11 +223,11 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
221223
222224 return nil
223225 }); err != nil {
224- return err
226+ return errors . WithStack ( err )
225227 }
226228 }
227229
228- l .Infof ("< %s applied successfully" , mi .Name )
230+ l .Infof ("%s applied successfully" , mi .Name )
229231 reverted ++
230232 }
231233 return nil
0 commit comments