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.

43 lines
826 B

10 years ago
  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 cmd
  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: `Fix provide upgrade from old version`,
  16. Action: runFix,
  17. Flags: []cli.Flag{},
  18. }
  19. func runFix(k *cli.Context) {
  20. execDir, _ := base.ExecDir()
  21. newLogger(execDir)
  22. base.NewConfigContext()
  23. models.LoadModelsConfig()
  24. if models.UseSQLite3 {
  25. os.Chdir(execDir)
  26. }
  27. models.SetEngine()
  28. err := models.Fix()
  29. if err != nil {
  30. fmt.Println(err)
  31. } else {
  32. fmt.Println("Fix successfully!")
  33. }
  34. }