photoprism/internal/entity/entity_fixtures.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

32 lines
682 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(false, nil))
Entities.WaitForMigration(Db())
Entities.Truncate(Db())
CreateDefaultFixtures()
CreateTestFixtures()
log.Debugf("migrate: recreated test fixtures [%s]", time.Since(start))
}