1599190683659_tables.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package version
  2. import (
  3. "runtime"
  4. "gorm.io/gorm"
  5. "git.cestong.com.cn/cecf/hx-admin-server/cmd/migrate/migration"
  6. "git.cestong.com.cn/cecf/hx-admin-server/cmd/migrate/migration/models"
  7. common "git.cestong.com.cn/cecf/hx-admin-server/common/models"
  8. )
  9. func init() {
  10. _, fileName, _, _ := runtime.Caller(0)
  11. migration.Migrate.SetVersion(migration.GetFilename(fileName), _1599190683659Tables)
  12. }
  13. func _1599190683659Tables(db *gorm.DB, version string) error {
  14. return db.Transaction(func(tx *gorm.DB) error {
  15. err := tx.Debug().Migrator().AutoMigrate(
  16. new(models.CasbinRule),
  17. new(models.SysDept),
  18. new(models.SysConfig),
  19. new(models.SysTables),
  20. new(models.SysColumns),
  21. new(models.SysMenu),
  22. new(models.SysLoginLog),
  23. new(models.SysOperaLog),
  24. new(models.SysRoleDept),
  25. new(models.SysUser),
  26. new(models.SysRole),
  27. new(models.SysPost),
  28. new(models.DictData),
  29. new(models.DictType),
  30. new(models.SysJob),
  31. new(models.SysConfig),
  32. new(models.SysApi),
  33. new(models.TbDemo),
  34. )
  35. if err != nil {
  36. return err
  37. }
  38. if err := models.InitDb(tx); err != nil {
  39. }
  40. return tx.Create(&common.Migration{
  41. Version: version,
  42. }).Error
  43. })
  44. }