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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user