photoprism/internal/entity/entity_fixtures.go
Michael Mayer 74772aea97 Config: Always initialize fixtures, even when skipping migrations #3215
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-02-21 04:44:08 +01:00

32 lines
688 B
Go

package entity
import (
"time"
"github.com/photoprism/photoprism/internal/migrate"
)
// CreateDefaultFixtures inserts default fixtures for test and production.
func CreateDefaultFixtures() {
CreateDefaultUsers()
CreateUnknownPlace()
CreateUnknownLocation()
CreateUnknownCountry()
CreateUnknownCamera()
CreateUnknownLens()
}
// ResetTestFixtures recreates database tables and test fixtures.
func ResetTestFixtures() {
start := time.Now()
Entities.Migrate(Db(), migrate.Opt(true, false, nil))
Entities.WaitForMigration(Db())
Entities.Truncate(Db())
CreateDefaultFixtures()
CreateTestFixtures()
log.Debugf("migrate: recreated test fixtures [%s]", time.Since(start))
}