mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-03 02:09:17 +02:00
added frontend and updated backend with docker, wrote some initial instructions
This commit is contained in:
34
backend/migrations/1695151278_add_admin_account.go
Normal file
34
backend/migrations/1695151278_add_admin_account.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db)
|
||||
|
||||
admin := &models.Admin{}
|
||||
admin.Email = "demo@htwkalender.de"
|
||||
err := admin.SetPassword("htwkalender-demo")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.SaveAdmin(admin)
|
||||
}, func(db dbx.Builder) error { // optional revert operation
|
||||
|
||||
dao := daos.New(db)
|
||||
|
||||
admin, _ := dao.FindAdminByEmail("test@example.com")
|
||||
if admin != nil {
|
||||
return dao.DeleteAdmin(admin)
|
||||
}
|
||||
|
||||
// already deleted
|
||||
return nil
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user