Commit cfc091e3 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Improve output of migrate status command on unknown migrations.

parent fb0977b1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org).

## [Unreleased]
### Changed
- Improve output of `nakama migrate status` command when database contains unknown migrations.

### Fixed
- Fix an issue with the JS runtime multiUpdate function.
+13 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ const (
type statusRow struct {
	ID        string
	Migrated  bool
	Unknown   bool
	AppliedAt time.Time
}

@@ -247,9 +248,16 @@ func (ms *migrationService) status(logger *zap.Logger) {
		}
	}

	unknownMigrations := make([]string, 0)
	for _, r := range records {
		rows[r.Id].Migrated = true
		rows[r.Id].AppliedAt = r.AppliedAt
		sr, ok := rows[r.Id]
		if !ok {
			// Unknown migration found in database, perhaps from a newer server version.
			unknownMigrations = append(unknownMigrations, r.Id)
			continue
		}
		sr.Migrated = true
		sr.AppliedAt = r.AppliedAt
	}

	for _, m := range migrations {
@@ -259,6 +267,9 @@ func (ms *migrationService) status(logger *zap.Logger) {
			logger.Info(m.Id, zap.String("applied", ""))
		}
	}
	for _, m := range unknownMigrations {
		logger.Warn(m, zap.String("applied", "unknown migration, check if database is set up for a newer server version"))
	}
}

func (ms *migrationService) parseSubcommand(args []string, logger *zap.Logger) {