mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 01:05:32 +00:00
Relationen, fehlt -PreferredTitle für Entries -Überflüssige Felder in Contents
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/migrations/seed"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/xmlmodels"
|
||||
@@ -10,17 +12,98 @@ import (
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
adb, err := xmlmodels.ReadAccessDB(xmlmodels.DATA_PATH)
|
||||
adb, err := xmlmodels.ReadAccessDB(xmlmodels.DATA_PATH, app.Logger())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*adb.Reihen = xmlmodels.SanitizeReihen(*adb.Reihen, *adb.Relationen_Bände_Reihen)
|
||||
adb.Reihen = xmlmodels.SanitizeReihen(adb.Reihen, adb.Relationen_Bände_Reihen)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(3)
|
||||
go func() {
|
||||
if records, err := seed.RecordsFromAkteure(app, adb.Akteure); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
if records, err := seed.RecordsFromOrte(app, adb.Orte); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
if records, err := seed.RecordsFromReihentitel(app, adb.Reihen); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
|
||||
if records, err := seed.RecordsFromBände(app, adb.Bände, adb.Orte); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if records, err := seed.ItemsFromBändeAndBIBLIO(app, adb.Bände, adb.BIBLIO); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if records, err := seed.RecordsFromInhalte(app, adb.Inhalte); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if records, err := seed.RecordsFromRelationBändeReihen(app, adb.Relationen_Bände_Reihen); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if records, err := seed.RecordsFromRelationBändeAkteure(app, adb.Relationen_Bände_Akteure); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if records, err := seed.RecordsFromRelationInhalteAkteure(app, adb.Relationen_Inhalte_Akteure); err == nil {
|
||||
if err = seed.BatchSave(app, records); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
seed.SeedTableAgents(app, *adb.Akteure)
|
||||
seed.SeedTablePlaces(app, *adb.Orte)
|
||||
seed.SeedTableSeries(app, *adb.Reihen)
|
||||
seed.SeedTableEntries(app, *adb.Bände, *adb.BIBLIO, *adb.Orte)
|
||||
return nil
|
||||
}, func(app core.App) error {
|
||||
return delete_data(app)
|
||||
@@ -30,8 +113,8 @@ func init() {
|
||||
func delete_data(app core.App) error {
|
||||
_ = deleteTableContents(app, dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.SERIES_TABLE))
|
||||
_ = deleteTableContents(app, dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.AGENTS_TABLE))
|
||||
_ = deleteTableContents(app, dbmodels.RelationTableName(dbmodels.PARTIALS_TABLE, dbmodels.AGENTS_TABLE))
|
||||
_ = deleteTableContents(app, dbmodels.PARTIALS_TABLE)
|
||||
_ = deleteTableContents(app, dbmodels.RelationTableName(dbmodels.CONTENTS_TABLE, dbmodels.AGENTS_TABLE))
|
||||
_ = deleteTableContents(app, dbmodels.CONTENTS_TABLE)
|
||||
_ = deleteTableContents(app, dbmodels.ENTRIES_TABLE)
|
||||
_ = deleteTableContents(app, dbmodels.SERIES_TABLE)
|
||||
_ = deleteTableContents(app, dbmodels.AGENTS_TABLE)
|
||||
|
||||
Reference in New Issue
Block a user