2021-11-21 14:05:07 +01:00
|
|
|
package entity
|
|
|
|
|
2022-01-05 18:15:39 +01:00
|
|
|
import (
|
|
|
|
"time"
|
2022-10-15 21:54:11 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/migrate"
|
2022-01-05 18:15:39 +01:00
|
|
|
)
|
|
|
|
|
2021-11-21 14:05:07 +01:00
|
|
|
// CreateDefaultFixtures inserts default fixtures for test and production.
|
|
|
|
func CreateDefaultFixtures() {
|
|
|
|
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-10-15 21:54:11 +02:00
|
|
|
Entities.Migrate(Db(), migrate.Opt(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
|
|
|
}
|