mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-11-24 17:07:00 +02:00
29 lines
685 B
Go
29 lines
685 B
Go
package migrations
|
|
|
|
import (
|
|
"github.com/pocketbase/dbx"
|
|
"github.com/pocketbase/pocketbase/daos"
|
|
"github.com/pocketbase/pocketbase/models"
|
|
)
|
|
|
|
// Resave all view collections to ensure that the proper id normalization is applied.
|
|
// (see https://github.com/pocketbase/pocketbase/issues/3110)
|
|
func init() {
|
|
AppMigrations.Register(func(db dbx.Builder) error {
|
|
dao := daos.New(db)
|
|
|
|
collections, err := dao.FindCollectionsByType(models.CollectionTypeView)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
for _, collection := range collections {
|
|
// ignore errors to allow users to adjust
|
|
// the view queries after app start
|
|
dao.SaveCollection(collection)
|
|
}
|
|
|
|
return nil
|
|
}, nil)
|
|
}
|