mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-29 19:43:57 +01:00
95299be52d
* Removejsonfile' from test matrix in workflows * Remove sqlite to json migration command * Refactor store engine implementation to remove JSON file store support The codebase has been refactored to remove support for JSON file store storage engine, with SQLite serving as the default store engine. New functions have been added to handle unsupported store engines and to migrate data from file store to SQLite. * Remove 'downCmd' from migration commands * Refactoring * Add sqlite cleanup * Remove comment
37 lines
962 B
Go
37 lines
962 B
Go
package cmd
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/netbirdio/netbird/management/server"
|
|
"github.com/netbirdio/netbird/util"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var shortUp = "Migrate JSON file store to SQLite store. Please make a backup of the JSON file before running this command."
|
|
|
|
var upCmd = &cobra.Command{
|
|
Use: "upgrade [--datadir directory] [--log-file console]",
|
|
Aliases: []string{"up"},
|
|
Short: shortUp,
|
|
Long: shortUp +
|
|
"\n\n" +
|
|
"This command reads the content of {datadir}/store.json and migrates it to {datadir}/store.db that can be used by SQLite store driver.",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
flag.Parse()
|
|
err := util.InitLog(logLevel, logFile)
|
|
if err != nil {
|
|
return fmt.Errorf("failed initializing log %v", err)
|
|
}
|
|
|
|
if err := server.MigrateFileStoreToSqlite(mgmtDataDir); err != nil {
|
|
return err
|
|
}
|
|
log.Info("Migration finished successfully")
|
|
|
|
return nil
|
|
},
|
|
}
|