Restore command (#593)
Add waiting for changes to config file Add max size for config files Restore files Restore database file Expose migrate to Move init stuff to seperate package Add restoring config file Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/593
This commit is contained in:
17
pkg/db/db.go
17
pkg/db/db.go
@ -168,3 +168,20 @@ func initSqliteEngine() (engine *xorm.Engine, err error) {
|
||||
|
||||
return xorm.NewEngine("sqlite3", path)
|
||||
}
|
||||
|
||||
// WipeEverything wipes all tables and their data. Use with caution...
|
||||
func WipeEverything() error {
|
||||
|
||||
tables, err := x.DBMetas()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, t := range tables {
|
||||
if err := x.DropTables(t.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -40,3 +40,15 @@ func Dump() (data map[string][]byte, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Restore restores a table with all its entries
|
||||
func Restore(table string, contents []map[string]interface{}) (err error) {
|
||||
|
||||
for _, content := range contents {
|
||||
if _, err := x.Table(table).Insert(content); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user