chore: add init db debug log
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user