-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 Add migration for default services, canCreateAccounts now defa…
…ults to true
- Loading branch information
1 parent
0bdfe91
commit ad34d82
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"forager": patch | ||
--- | ||
|
||
Add migration for default services, canCreateAccounts now defaults to true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
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) | ||
|
||
collection, err := dao.FindCollectionByNameOrId("Services") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
record := models.NewRecord(collection) | ||
|
||
record.Set("id", 1) | ||
record.Set("canCreateAccounts", true) | ||
|
||
err = dao.SaveRecord(record) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, func(db dbx.Builder) error { | ||
dao := daos.New(db) | ||
|
||
collection, err := dao.FindCollectionByNameOrId("Services") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
record, err := dao.FindRecordById(collection.Id, "1") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = dao.DeleteRecord(record) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}) | ||
} |