first commit

This commit is contained in:
Leandro Afonso
2025-10-19 20:47:58 +01:00
commit 63f850d705
80 changed files with 8358 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package migrations
import (
"os"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
// add up queries...
// get environment variable
email := os.Getenv("SUPERUSER_EMAIL")
password := os.Getenv("SUPERUSER_PASSWORD")
if email == "" || password == "" {
return nil
}
superusers, err := app.FindCollectionByNameOrId(core.CollectionNameSuperusers)
if err != nil {
return err
}
record := core.NewRecord(superusers)
// note: the values can be eventually loaded via os.Getenv(key)
// or from a special local config file
record.Set("email", email)
record.Set("password", password)
return app.Save(record)
}, func(app core.App) error {
// add down queries...
return nil
})
}