本站源代码
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.

42 lines
1.1KB

  1. // Copyright 2018 The Gitea 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. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/models/migrations"
  8. "code.gitea.io/gitea/modules/log"
  9. "code.gitea.io/gitea/modules/setting"
  10. "github.com/urfave/cli"
  11. )
  12. // CmdMigrate represents the available migrate sub-command.
  13. var CmdMigrate = cli.Command{
  14. Name: "migrate",
  15. Usage: "Migrate the database",
  16. Description: "This is a command for migrating the database, so that you can run gitea admin create-user before starting the server.",
  17. Action: runMigrate,
  18. }
  19. func runMigrate(ctx *cli.Context) error {
  20. if err := initDB(); err != nil {
  21. return err
  22. }
  23. log.Trace("AppPath: %s", setting.AppPath)
  24. log.Trace("AppWorkPath: %s", setting.AppWorkPath)
  25. log.Trace("Custom path: %s", setting.CustomPath)
  26. log.Trace("Log path: %s", setting.LogRootPath)
  27. setting.InitDBConfig()
  28. if err := models.NewEngine(migrations.Migrate); err != nil {
  29. log.Fatal("Failed to initialize ORM engine: %v", err)
  30. return err
  31. }
  32. return nil
  33. }
上海开阖软件有限公司 沪ICP备12045867号-1