deleted bad migfration structure

This commit is contained in:
Simon Martens
2025-05-21 21:47:30 +02:00
parent 9642e53474
commit 6e2aa51092
17 changed files with 133 additions and 130 deletions

View File

@@ -0,0 +1,42 @@
package migrations
import (
"github.com/Theodor-Springmann-Stiftung/musenalm/pagemodels"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
const TITLE_KONTAKT = "Kontakt"
const TEXT_KONTAKT = `<p>Martin Sietzen und Dr. Jakob Br&uuml;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_KONTAKT = "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(TITLE_KONTAKT)
record.SetText(TEXT_KONTAKT)
record.SetDescription(BESCHREIBUNG_KONTAKT)
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
})
}