Skip to content

Commit

Permalink
Fix --major
Browse files Browse the repository at this point in the history
  • Loading branch information
MMulthaupt committed Feb 8, 2021
1 parent 1b498d9 commit 9ee642e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ func nextFlywayScriptPrefix(folderPath string, incrementMethod flags.VersionIncr
}

func extractSchemaName(scriptPrefix string) string {
adminIndex := strings.Index(scriptPrefix, "_admin")
if adminIndex == 3 {
if strings.Index(scriptPrefix, "_admin") == 3 {
return "schema_admin"
}
if adminIndex > 3 {
if strings.HasSuffix(scriptPrefix, "_admin") {
return "schema_client_admin"
}
return "schema_client"
Expand All @@ -52,7 +51,7 @@ func nextFlywayScriptVersion(folderPath string, incrementMethod flags.VersionInc
return incrementFlywayScriptVersion("000", "000", incrementMinor)
}
major, minor, _ = getFlywayScriptVersion(latestScriptFileName)
return incrementFlywayScriptVersion(major, minor, wasMinorIncrement)
return incrementFlywayScriptVersion(major, minor, incrementMinor)
}

func latestFlywayScriptFileName(folderPath string) (scriptFileName string, wasMinorIncrement bool) {
Expand Down Expand Up @@ -91,7 +90,7 @@ func incrementFlywayScriptVersion(major, minor string, incrementMinor bool) (new
if incrementMinor {
return major, fmt.Sprintf(fmt.Sprintf("%%0%dd", len(minor)), atoi(minor)+1)
}
return fmt.Sprintf(fmt.Sprintf("%%0%dd", len(major)), atoi(major)+1), fmt.Sprintf(fmt.Sprintf("%%%d0d", len(minor)), 1)
return fmt.Sprintf(fmt.Sprintf("%%0%dd", len(major)), atoi(major)+1), fmt.Sprintf(fmt.Sprintf("%%0%dd", len(minor)), 1)
}

func atoi(s string) int {
Expand Down

0 comments on commit 9ee642e

Please sign in to comment.