Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InitAdmin = &gormigrate.Migration{ ID: "init_admin", Migrate: func(tx *gorm.DB) error { var err error type adminUser struct { ID uint64 `json:"id,omitempty"` Email string `gorm:"not null;unique"` FirstName string LastName string Password string Username string `json:"username,omitempty"` Role string `json:"role,omitempty"` LastLogin *time.Time CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time } if err = tx.CreateTable(&adminUser{}).Error; err != nil { go utils.LogErrToFile(err.Error()) return err } var pwd []byte if pwd, err = bcrypt.GenerateFromPassword([]byte("1234567"), bcrypt.DefaultCost); err != nil { go utils.LogErrToFile(err.Error()) return err } usr := adminUser{ ID: 1, Email: "root@gmail.com", FirstName: "root", LastName: "root", Username: "root", Role: models.Role.ROOT, Password: string(pwd), } return tx.Save(&usr).Error }, Rollback: func(tx *gorm.DB) error { return tx.DropTable("admin_users").Error }, }
InitAdmin ...
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.