Implement cache migrations
This commit is contained in:
8
internal/cache/cache.go
vendored
8
internal/cache/cache.go
vendored
@@ -14,6 +14,8 @@ import (
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
const cacheVersion = "v0.1.0"
|
||||
|
||||
type Cache struct {
|
||||
Projects []*projects.Project
|
||||
Aliases []*ProjectAlias
|
||||
@@ -27,6 +29,7 @@ type Cache struct {
|
||||
file string
|
||||
log *pterm.Logger
|
||||
path string
|
||||
CacheVersion string
|
||||
}
|
||||
|
||||
type CacheOpts struct {
|
||||
@@ -118,6 +121,11 @@ func (c *Cache) Read() error {
|
||||
d := yaml.NewDecoder(file)
|
||||
d.Decode(c)
|
||||
|
||||
// Perform migrations
|
||||
if err := c.doMigrations(); err != nil {
|
||||
c.log.Error("Failed to run cache migrations", c.log.Args("error", err))
|
||||
}
|
||||
|
||||
c.readFromFile = true
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user