lock the _mfas and _otps delete api rule, fixed flaky tests, fixed jsvm types example

This commit is contained in:
Gani Georgiev
2024-10-24 21:59:00 +03:00
parent 0b7741f1f7
commit 8c45d4d92d
13 changed files with 5639 additions and 5307 deletions

View File

@@ -0,0 +1,35 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
)
// note: this migration will be deleted in future version
func init() {
core.SystemMigrations.Register(func(txApp core.App) error {
_, err := txApp.DB().NewQuery("CREATE INDEX IF NOT EXISTS idx__collections_type on {{_collections}} ([[type]]);").Execute()
if err != nil {
return err
}
// reset mfas and otps delete rule
collectionNames := []string{core.CollectionNameMFAs, core.CollectionNameOTPs}
for _, name := range collectionNames {
col, err := txApp.FindCollectionByNameOrId(name)
if err != nil {
return err
}
if col.DeleteRule != nil {
col.DeleteRule = nil
err = txApp.SaveNoValidate(col)
if err != nil {
return err
}
}
}
return nil
}, nil)
}