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.

35 lines
774 B

3 years ago
3 years ago
3 years ago
  1. package initialize
  2. import (
  3. "os"
  4. "autocode/global"
  5. "autocode/model/autocode"
  6. "go.uber.org/zap"
  7. "gorm.io/gorm"
  8. )
  9. // Gorm 初始化数据库并产生数据库全局变量
  10. // Author SliverHorn
  11. func Gorm() *gorm.DB {
  12. return GormInit()
  13. }
  14. // RegisterTables 注册数据库表专用
  15. // Author SliverHorn
  16. func RegisterTables(db *gorm.DB) {
  17. err := db.AutoMigrate(
  18. // 自动化模块表
  19. // Code generated by github.com/flipped-aurora/yibu/server Begin; DO NOT EDIT.
  20. autocode.AutoCodeExample{},
  21. autocode.UserInfo{},
  22. autocode.Ercode{},
  23. // Code generated by github.com/flipped-aurora/yibu/server End; DO NOT EDIT.
  24. )
  25. if err != nil {
  26. global.GVA_LOG.Error("register table failed", zap.Error(err))
  27. os.Exit(0)
  28. }
  29. global.GVA_LOG.Info("register table success")
  30. }