Example #1
0
func DropTables(db *gorm.DB) error {
	err := db.DropTable(UserFileInfo{}).Error
	if err != nil {
		return err
	}
	return db.DropTable(UserFile{}).Error
}
Example #2
0
func InitTable(DB *gorm.DB) *gorm.DB {

	DB.DropTable(&User{})
	DB.AutoMigrate(&User{})

	account.InitTable(DB)

	createTestUser(DB)
	return DB
}
Example #3
0
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})
}
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{})
}
Example #5
0
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
}
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
}
Example #7
0
func DropTables(db *gorm.DB) error {
	return db.DropTable(MaillistUser{}).Error
}
Example #8
0
func testShutdown(t *testing.T, db *gorm.DB) {
	err := db.DropTable(&Test{}).Error
	assert.Equal(t, nil, err, "error while droped table in DB")
}
Example #9
0
func DropTables(db *gorm.DB) error {
	return db.DropTable(UserAuth{}).Error
}
Example #10
0
func InitTable(DB *gorm.DB) *gorm.DB {
	DB.DropTable(&Account{})
	DB.AutoMigrate(&Account{})
	return DB
}