本文整理汇总了Golang中github.com/jinzhu/gorm.DB.DropTable方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.DropTable方法的具体用法?Golang DB.DropTable怎么用?Golang DB.DropTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jinzhu/gorm.DB
的用法示例。
在下文中一共展示了DB.DropTable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DropTables
func DropTables(db *gorm.DB) error {
err := db.DropTable(UserFileInfo{}).Error
if err != nil {
return err
}
return db.DropTable(UserFile{}).Error
}
示例2: InitTable
func InitTable(DB *gorm.DB) *gorm.DB {
DB.DropTable(&User{})
DB.AutoMigrate(&User{})
account.InitTable(DB)
createTestUser(DB)
return DB
}
示例3: seedDb
func seedDb(db *gorm.DB) {
db.DropTable(&User{})
db.CreateTable(&User{})
user1 := User{Name: "user1", Password: "user1"}
user2 := User{Name: "user2", Password: "user2"}
admin := User{Name: "admin", Password: "admin", Admin: true}
db.Create(&user1)
db.Create(&user2)
db.Create(&admin)
db.DropTable(&PrivateWidget{})
db.CreateTable(&PrivateWidget{})
db.Create(&PrivateWidget{Name: "User 1's Widget", UserID: user1.ID})
db.Create(&PrivateWidget{Name: "User 2's Widget", UserID: user2.ID})
}
示例4: MigrationsUp
func MigrationsUp(db *gorm.DB) {
log.Println("Starting migrations")
// Drop table
db.DropTable(&User{}, &Phone{}, &Email{}, &Language{})
// Create table
//db.CreateTable(&User{})
db.Set("gorm:table_options", "ENGINE=InnoDB").CreateTable(&User{}, &Phone{}, &Email{}, &Language{})
// ModifyColumn
//db.Model(&User{}).ModifyColumn("description", "text")
// DropColumn
//db.Model(&User{}).DropColumn("description")
// Automating Migration
db.AutoMigrate(&User{}, &Phone{}, &Email{}, &Language{})
}
示例5: DropTables
func DropTables(db *gorm.DB) error {
var err error
err = db.DropTable(Visitor{}).Error
if err != nil {
return err
}
err = db.DropTable(UserBasic{}).Error
if err != nil {
return err
}
err = db.DropTable(UserAddress{}).Error
if err != nil {
return err
}
err = db.DropTable(UserPhone{}).Error
if err != nil {
return err
}
err = db.DropTable(UserProfileElement{}).Error
if err != nil {
return err
}
return nil
}
示例6: DropTables
func DropTables(db *gorm.DB) error {
var err error
err = db.DropTable(VisitorPageRequest{}).Error
if err != nil {
return err
}
err = db.DropTable(VisitorMouseEvents{}).Error
if err != nil {
return err
}
err = db.DropTable(VisitorKeyboardEvents{}).Error
if err != nil {
return err
}
err = db.DropTable(UserPageRequest{}).Error
if err != nil {
return err
}
err = db.DropTable(UserMouseEvents{}).Error
if err != nil {
return err
}
err = db.DropTable(UserKeyboardEvents{}).Error
if err != nil {
return err
}
return nil
}
示例7: DropTables
func DropTables(db *gorm.DB) error {
return db.DropTable(MaillistUser{}).Error
}
示例8: testShutdown
func testShutdown(t *testing.T, db *gorm.DB) {
err := db.DropTable(&Test{}).Error
assert.Equal(t, nil, err, "error while droped table in DB")
}
示例9: DropTables
func DropTables(db *gorm.DB) error {
return db.DropTable(UserAuth{}).Error
}
示例10: InitTable
func InitTable(DB *gorm.DB) *gorm.DB {
DB.DropTable(&Account{})
DB.AutoMigrate(&Account{})
return DB
}