mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-01-24 22:32:42 +02:00
36 lines
787 B
Go
36 lines
787 B
Go
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)
|
|
}
|