1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-28 02:02:01 +02:00

removed unused automigrate methods and updated changelog

This commit is contained in:
Gani Georgiev 2022-11-29 22:28:38 +02:00
parent a4953cbb4e
commit 9ba710cdc5
3 changed files with 4 additions and 55 deletions

View File

@ -103,6 +103,8 @@
filesystem.Serve(res, req, e.ServedPath, e.ServedName)
```
- Fixed concurrent multi-relation cascade update/delete ([#1138](https://github.com/pocketbase/pocketbase/issues/1138)).
## v0.8.0

View File

@ -6,13 +6,10 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"time"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
"github.com/pocketbase/pocketbase/tools/list"
)
const collectionsCacheKey = "migratecmd_collections"
@ -31,7 +28,7 @@ func (p *plugin) afterCollectionChange() func(*core.ModelEvent) error {
return err
}
old, _ := oldCollections[e.Model.GetId()]
old := oldCollections[e.Model.GetId()]
new, err := p.app.Dao().FindCollectionByNameOrId(e.Model.GetId())
if err != nil && !errors.Is(err, sql.ErrNoRows) {
@ -108,53 +105,3 @@ func (p *plugin) getCachedCollections() (map[string]*models.Collection, error) {
return result, nil
}
// getAllMigrationNames return sorted slice with both applied and new
// local migration file names.
func (p *plugin) getAllMigrationNames() ([]string, error) {
names := []string{}
for _, migration := range m.AppMigrations.Items() {
names = append(names, migration.File)
}
localFiles, err := p.getLocalMigrationNames()
if err != nil {
return nil, err
}
for _, name := range localFiles {
if !list.ExistInSlice(name, names) {
names = append(names, name)
}
}
sort.Slice(names, func(i int, j int) bool {
return names[i] < names[j]
})
return names, nil
}
// getLocalMigrationNames returns a list with all local migration files
//
// Returns an empty slice if the migrations directory doesn't exist.
func (p *plugin) getLocalMigrationNames() ([]string, error) {
files, err := os.ReadDir(p.options.Dir)
if err != nil {
if os.IsNotExist(err) {
return []string{}, nil
}
return nil, err
}
result := make([]string, 0, len(files))
for _, f := range files {
if f.IsDir() {
continue
}
result = append(result, f.Name())
}
return result, nil
}

View File

@ -720,7 +720,7 @@ func marhshalWithoutEscape(v any, prefix string, indent string) ([]byte, error)
}
// unescape escaped unicode characters
unescaped, err := strconv.Unquote(strings.Replace(strconv.Quote(string(raw)), `\\u`, `\u`, -1))
unescaped, err := strconv.Unquote(strings.ReplaceAll(strconv.Quote(string(raw)), `\\u`, `\u`))
if err != nil {
return nil, err
}