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

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

	account.InitTable(DB)

	createTestUser(DB)
	return DB
}
Exemplo n.º 3
0
func seedDb(db *gorm.DB) {
	db.DropTable(&User{})
	db.CreateTable(&User{})
	user1 := User{Name: "user1", Password: "******"}
	user2 := User{Name: "user2", Password: "******"}
	admin := User{Name: "admin", Password: "******", 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})
}
Exemplo n.º 4
0
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{})
}
Exemplo n.º 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
}
Exemplo n.º 6
0
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
}
Exemplo n.º 7
0
func DropTables(db *gorm.DB) error {
	return db.DropTable(MaillistUser{}).Error
}
Exemplo n.º 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")
}
Exemplo n.º 9
0
func DropTables(db *gorm.DB) error {
	return db.DropTable(UserAuth{}).Error
}
Exemplo n.º 10
0
func InitTable(DB *gorm.DB) *gorm.DB {
	DB.DropTable(&Account{})
	DB.AutoMigrate(&Account{})
	return DB
}