2021-11-21 14:05:07 +01:00
|
|
|
package entity
|
|
|
|
|
2022-01-05 18:15:39 +01:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-11-21 14:05:07 +01:00
|
|
|
// CreateDefaultFixtures inserts default fixtures for test and production.
|
|
|
|
func CreateDefaultFixtures() {
|
|
|
|
CreateUnknownAddress()
|
|
|
|
CreateDefaultUsers()
|
|
|
|
CreateUnknownPlace()
|
|
|
|
CreateUnknownLocation()
|
|
|
|
CreateUnknownCountry()
|
|
|
|
CreateUnknownCamera()
|
|
|
|
CreateUnknownLens()
|
|
|
|
}
|
|
|
|
|
2022-01-05 18:15:39 +01:00
|
|
|
// ResetTestFixtures recreates database tables and test fixtures.
|
2021-11-21 14:05:07 +01:00
|
|
|
func ResetTestFixtures() {
|
2022-01-05 18:15:39 +01:00
|
|
|
start := time.Now()
|
|
|
|
|
2022-03-30 20:36:25 +02:00
|
|
|
Entities.Migrate(Db(), false, nil)
|
2021-11-28 13:52:27 +01:00
|
|
|
Entities.WaitForMigration(Db())
|
|
|
|
Entities.Truncate(Db())
|
2021-11-21 14:05:07 +01:00
|
|
|
|
|
|
|
CreateDefaultFixtures()
|
|
|
|
|
|
|
|
CreateTestFixtures()
|
2022-01-05 18:15:39 +01:00
|
|
|
|
2022-04-04 14:21:43 +02:00
|
|
|
log.Debugf("migrate: recreated test fixtures [%s]", time.Since(start))
|
2021-11-21 14:05:07 +01:00
|
|
|
}
|