Пример #1
0
func (s Notifications) ResetDatabase() {
	env := application.NewEnvironment()
	database, gobbleDB := fetchDatabases()

	v1models.Setup(database)
	v2models.Setup(database)
	database.Connection().(*db.Connection).TruncateTables()

	migrator := v1models.DatabaseMigrator{}
	migrator.Seed(database, path.Join(env.RootPath, "templates", "default.json"))

	gobbleDB.Connection.TruncateTables()
}
Пример #2
0
func TruncateTables(database *db.DB) {
	env := application.NewEnvironment()
	dbMigrator := v1models.DatabaseMigrator{}
	dbMigrator.Migrate(database.RawConnection(), env.ModelMigrationsPath)
	v1models.Setup(database)
	v2models.Setup(database)

	connection := database.Connection().(*db.Connection)
	err := connection.TruncateTables()
	if err != nil {
		panic(err)
	}
}