mirror of
https://github.com/usual2970/certimate.git
synced 2025-07-28 09:28:33 +00:00
.github
.vscode
docker
internal
migrations
1724677539_update_admin.go
1726147254_collections_snapshot.go
1726147268_update_access_usage.go
1726184067_collections_snapshot.go
1726299230_collections_snapshot.go
1729671262_collections_snapshot.go
1730766480_collections_snapshot.go
ui
.dockerignore
.editorconfig
.gitignore
.goreleaser.yml
CHANGELOG.md
CONTRIBUTING.md
CONTRIBUTING_EN.md
Dockerfile
LICENSE.md
Makefile
README.md
README_EN.md
go.mod
go.sum
main.go
nixpacks.toml
usage.gif
30 lines
639 B
Go
30 lines
639 B
Go
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 {
|
|
// add up queries...
|
|
dao := daos.New(db)
|
|
|
|
admin := &models.Admin{}
|
|
admin.Email = "admin@certimate.fun"
|
|
admin.SetPassword("1234567890")
|
|
return dao.SaveAdmin(admin)
|
|
}, func(db dbx.Builder) error {
|
|
// add down queries...
|
|
dao := daos.New(db)
|
|
|
|
admin, _ := dao.FindAdminByEmail("admin@certimate.fun")
|
|
if admin != nil {
|
|
return dao.DeleteAdmin(admin)
|
|
}
|
|
return nil
|
|
})
|
|
}
|