switch to postgresql
Some checks failed
CI / test-build (push) Has been cancelled

This commit is contained in:
2025-12-16 01:31:27 +07:00
parent 27b0400ef3
commit a7ba6c83ea
10 changed files with 544 additions and 127 deletions

View File

@@ -26,7 +26,7 @@ type Config struct {
Addr string
TemplatesDir string
StaticDir string
DatabasePath string // Path to SQLite database (empty = in-memory mode)
DatabaseConn string // Database connection string (SQLite path or PostgreSQL connection string, empty = in-memory mode)
}
type App struct {
@@ -103,8 +103,8 @@ func New(cfg Config) (*App, error) {
// Initialize database (optional)
var database *db.DB
if cfg.DatabasePath != "" {
dbConn, err := db.New(cfg.DatabasePath)
if cfg.DatabaseConn != "" {
dbConn, err := db.New(cfg.DatabaseConn)
if err != nil {
return nil, fmt.Errorf("init database: %w", err)
}

View File

@@ -32,7 +32,7 @@ func (a *App) handleCreateBackup(w http.ResponseWriter, r *http.Request) {
ISCSITargets: a.iscsiStore.List(),
Policies: a.snapshotPolicy.List(),
Config: map[string]interface{}{
"database_path": a.cfg.DatabasePath,
"database_conn": a.cfg.DatabaseConn,
},
}

View File

@@ -119,7 +119,7 @@ func (a *App) handleSystemInfo(w http.ResponseWriter, r *http.Request) {
if a.database != nil {
info.Database = DatabaseInfo{
Connected: true,
Path: a.cfg.DatabasePath,
Path: a.cfg.DatabaseConn,
}
}

View File

@@ -77,7 +77,7 @@ func (a *App) handleEnableMaintenance(w http.ResponseWriter, r *http.Request) {
ISCSITargets: a.iscsiStore.List(),
Policies: a.snapshotPolicy.List(),
Config: map[string]interface{}{
"database_path": a.cfg.DatabasePath,
"database_conn": a.cfg.DatabaseConn,
},
}