first commit
This commit is contained in:
33
backend/cmd/reset_state/main.go
Normal file
33
backend/cmd/reset_state/main.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"filefast/backend/internal/config"
|
||||
"filefast/backend/internal/storage"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
|
||||
client, err := storage.NewSQLiteClient(cfg.SQLite)
|
||||
if err != nil {
|
||||
log.Fatalf("init sqlite client failed: %v", err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := client.Ping(ctx); err != nil {
|
||||
log.Fatalf("ping sqlite failed: %v", err)
|
||||
}
|
||||
|
||||
if err := client.ResetOperationalData(ctx); err != nil {
|
||||
log.Fatalf("reset operational data failed: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("reset completed for operational tables in %s", cfg.SQLite.Path)
|
||||
}
|
||||
Reference in New Issue
Block a user