You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
811 B

  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package main
  5. import (
  6. "fmt"
  7. "os"
  8. "github.com/codegangsta/cli"
  9. "github.com/gogits/gogs/models"
  10. "github.com/gogits/gogs/modules/base"
  11. )
  12. var CmdFix = cli.Command{
  13. Name: "fix",
  14. Usage: "This command for upgrade from old version",
  15. Description: `
  16. gogs fix provide upgrade from old version`,
  17. Action: runFix,
  18. Flags: []cli.Flag{},
  19. }
  20. func runFix(k *cli.Context) {
  21. execDir, _ := base.ExecDir()
  22. newLogger(execDir)
  23. base.NewConfigContext()
  24. models.LoadModelsConfig()
  25. if models.UseSQLite3 {
  26. os.Chdir(execDir)
  27. }
  28. models.SetEngine()
  29. err := models.Fix()
  30. if err != nil {
  31. fmt.Println(err)
  32. } else {
  33. fmt.Println("Fix successfully!")
  34. }
  35. }