浏览代码

fix(member): use client/orm insteal of adapter/orm

- to avoid type check bug when comparing error, use newer api instead of
old adapter
roberChen 4 年之前
父节点
当前提交
d069b7c515
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      commands/install.go

+ 5 - 2
commands/install.go

@@ -1,13 +1,14 @@
 package commands
 
 import (
+	"errors"
 	"fmt"
 	"os"
 	"time"
 
 	"flag"
 
-	"github.com/beego/beego/v2/adapter/orm"
+	"github.com/beego/beego/v2/client/orm"
 	"github.com/beego/beego/v2/core/logs"
 	"github.com/mindoc-org/mindoc/conf"
 	"github.com/mindoc-org/mindoc/models"
@@ -101,7 +102,7 @@ func initialization() {
 	}
 
 	member, err := models.NewMember().FindByFieldFirst("account", "admin")
-	if err == orm.ErrNoRows {
+	if errors.Is(err, orm.ErrNoRows) {
 
 		// create admin user
 		logs.Info("creating admin user")
@@ -139,6 +140,8 @@ func initialization() {
 		if err := book.Insert(); err != nil {
 			panic("初始化项目失败 -> " + err.Error())
 		}
+	} else if err != nil {
+		panic(fmt.Errorf("occur errors when initialize: %s", err))
 	}
 
 	if !models.NewItemsets().Exist(1) {