fix: Implement database creation in RestoreSingle

BUG #1: restore single --create flag was not implemented
- Added ensureDatabaseExists() call when createIfMissing=true
- Database is now created before restore if --create flag is used
- Added TEST_PLAN.md with comprehensive testing matrix

Tested: restore single --create flag now works correctly
Before: ERROR: database does not exist
After: Database created successfully and restored
This commit is contained in:
2025-11-10 09:03:36 +00:00
parent bdbd8d5e54
commit cd948e84f1
2 changed files with 260 additions and 0 deletions

View File

@@ -116,6 +116,15 @@ func (e *Engine) RestoreSingle(ctx context.Context, archivePath, targetDB string
// Start progress tracking
e.progress.Start(fmt.Sprintf("Restoring database '%s' from %s", targetDB, filepath.Base(archivePath)))
// Create database if requested and it doesn't exist
if createIfMissing {
e.log.Info("Checking if target database exists", "database", targetDB)
if err := e.ensureDatabaseExists(ctx, targetDB); err != nil {
operation.Fail(fmt.Sprintf("Failed to create database: %v", err))
return fmt.Errorf("failed to create database '%s': %w", targetDB, err)
}
}
// Handle different archive formats
var err error
switch format {