removed unused automigrate methods and updated changelog
This commit is contained in:
parent
a4953cbb4e
commit
9ba710cdc5
|
@ -103,6 +103,8 @@
|
||||||
filesystem.Serve(res, req, e.ServedPath, e.ServedName)
|
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
|
## v0.8.0
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pocketbase/pocketbase/core"
|
"github.com/pocketbase/pocketbase/core"
|
||||||
m "github.com/pocketbase/pocketbase/migrations"
|
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"github.com/pocketbase/pocketbase/models"
|
||||||
"github.com/pocketbase/pocketbase/tools/list"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const collectionsCacheKey = "migratecmd_collections"
|
const collectionsCacheKey = "migratecmd_collections"
|
||||||
|
@ -31,7 +28,7 @@ func (p *plugin) afterCollectionChange() func(*core.ModelEvent) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
old, _ := oldCollections[e.Model.GetId()]
|
old := oldCollections[e.Model.GetId()]
|
||||||
|
|
||||||
new, err := p.app.Dao().FindCollectionByNameOrId(e.Model.GetId())
|
new, err := p.app.Dao().FindCollectionByNameOrId(e.Model.GetId())
|
||||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||||
|
@ -108,53 +105,3 @@ func (p *plugin) getCachedCollections() (map[string]*models.Collection, error) {
|
||||||
|
|
||||||
return result, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -720,7 +720,7 @@ func marhshalWithoutEscape(v any, prefix string, indent string) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unescape escaped unicode characters
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue