mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-28 16:55:32 +00:00
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
package migrations_kontakt
|
|
|
|
import (
|
|
"github.com/Theodor-Springmann-Stiftung/musenalm/pagemodels"
|
|
"github.com/pocketbase/pocketbase/core"
|
|
m "github.com/pocketbase/pocketbase/migrations"
|
|
)
|
|
|
|
const START = `<p>Martin Sietzen und Dr. Jakob Brüssermann<br>Theodor-Springmann-Stiftung<br>Hirschgasse 2 <br><br>69120 Heidelberg<br><a href="mailto:info@musenalm.de">info@musenalm.de</a></p>`
|
|
|
|
const BESCHREIBUNG = "Musenalm: Verzeichnis deutschsprachiger Almanache des 18. und 19. Jahrhunderts. Kontakt zur Redaktion."
|
|
|
|
func init() {
|
|
m.Register(func(app core.App) error {
|
|
collection, err := app.FindCollectionByNameOrId(
|
|
pagemodels.GeneratePageTableName(pagemodels.P_KONTAKT_NAME))
|
|
if err != nil {
|
|
app.Logger().Error("Could not find Table Reihen! You need to execute table migrations first!")
|
|
return err
|
|
}
|
|
|
|
record := pagemodels.NewTextPage(core.NewRecord(collection))
|
|
record.SetTitle("Kontakt")
|
|
record.SetText(START)
|
|
record.SetDescription(BESCHREIBUNG)
|
|
|
|
if err := app.Save(record); err != nil {
|
|
app.Logger().Error("Failed to save record", "error", err, "record", record)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}, func(app core.App) error {
|
|
coll, err := app.FindCollectionByNameOrId(
|
|
pagemodels.GeneratePageTableName(pagemodels.P_KONTAKT_NAME))
|
|
|
|
if err == nil && coll != nil {
|
|
app.DB().NewQuery("DELETE FROM " + coll.TableName()).Execute()
|
|
}
|
|
return nil
|
|
})
|
|
}
|