chore: add init db debug log

This commit is contained in:
zhaoyupeng
2025-10-31 22:23:35 +08:00
parent 36fd04cac9
commit 42331cde57
2 changed files with 22 additions and 17 deletions

View File

@@ -5,21 +5,21 @@ import (
)
func TestNew(t *testing.T) {
//mdb, err := New(WithMysql("127.0.0.1", 3306, "root", "MyPassw0rd", "mydb"))
//if err != nil {
// t.Fatal(err)
//}
//
//type User struct {
// Id uint64 `gorm:"primaryKey"`
// Username string `gorm:"unique"`
//}
//
//if err = mdb.Session(t.Context()).AutoMigrate(&User{}); err != nil {
// t.Fatal(err)
//}
//
//if err = mdb.Session(t.Context()).Create(&User{Username: "zyp"}).Error; err != nil {
// t.Fatal(err)
//}
mdb, err := New(WithMysql("127.0.0.1", 2881, "yizhi@test", "yizhi", "mie"))
if err != nil {
t.Fatal(err)
}
type User struct {
Id uint64 `gorm:"primaryKey"`
Username string `gorm:"unique"`
}
if err = mdb.Session(t.Context()).AutoMigrate(&User{}); err != nil {
t.Fatal(err)
}
if err = mdb.Session(t.Context()).Create(&User{Username: "zyp"}).Error; err != nil {
t.Fatal(err)
}
}