initial data & migrations

This commit is contained in:
Simon Martens
2025-02-07 17:42:10 +01:00
parent 45f28effe8
commit 7ff6bd9d28
85 changed files with 2481809 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
package migrations
import (
"github.com/Theodor-Springmann-Stiftung/musenalm/models"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
agents := agentsTable()
agents.Fields = agentsFields(agents)
agentsIndexes(agents)
return app.Save(agents)
}, func(app core.App) error {
agents, err := app.FindCollectionByNameOrId(models.AGENTS_TABLE)
if err != nil {
return nil
}
return app.Delete(agents)
})
}
func agentsTable() *core.Collection {
collection := core.NewBaseCollection(models.AGENTS_TABLE)
setBasicPublicRules(collection)
return collection
}
func agentsFields(collection *core.Collection) core.FieldsList {
fields := core.NewFieldsList(
&core.TextField{Name: "name", Required: true, Presentable: true},
&core.BoolField{Name: "corporate_body", Required: false},
&core.BoolField{Name: "fictional", Required: false},
&core.URLField{Name: "registry_domains", Required: false},
&core.TextField{Name: "biographical_data", Required: false, Presentable: true},
&core.TextField{Name: "profession", Required: false},
&core.TextField{Name: "pseudonyms", Required: false},
&core.TextField{Name: "references", Required: false},
)
setMusenalmIDField(&fields)
setEditorStateField(&fields)
setNotesAndAnnotationsField(&fields)
return fields
}
func agentsIndexes(collection *core.Collection) {
addMusenalmIDIndex(collection)
addIndex(collection, "name", false)
}