@deinossrl/dgp-agent 1.4.56 → 1.4.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/index.mjs +39 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog - DGP Agent
|
|
2
2
|
|
|
3
|
+
## [1.4.58] - 2026-01-12
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Eliminado `--exit-on-error` por defecto en pg_restore
|
|
7
|
+
- Ahora distingue entre errores críticos y warnings de DROP
|
|
8
|
+
- Restauración continúa aunque schemas/objetos no existan previamente
|
|
9
|
+
- pg_restore crea schemas automáticamente según el backup
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Exit code 1 con warnings se considera exitoso si no hay errores críticos
|
|
13
|
+
- Mejores logs que muestran warnings sin fallar la restauración
|
|
14
|
+
|
|
15
|
+
## [1.4.57] - 2026-01-12
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Agregado `--if-exists` a pg_restore para evitar errores con DROP de objetos inexistentes
|
|
19
|
+
- `--exit-on-error` ahora solo se usa si skip_errors es false
|
|
20
|
+
- Resuelve error "policy does not exist" durante restore
|
|
21
|
+
|
|
3
22
|
## [1.4.56] - 2026-01-12
|
|
4
23
|
|
|
5
24
|
### Fixed
|
package/index.mjs
CHANGED
|
@@ -1987,6 +1987,7 @@ async function executePgRestore(command) {
|
|
|
1987
1987
|
// Opciones de restore
|
|
1988
1988
|
if (clean_before_restore) {
|
|
1989
1989
|
pgRestoreArgs.push('--clean');
|
|
1990
|
+
pgRestoreArgs.push('--if-exists'); // Solo borrar si existe (evita errores)
|
|
1990
1991
|
}
|
|
1991
1992
|
|
|
1992
1993
|
if (restore_type === 'schema_only') {
|
|
@@ -1995,8 +1996,15 @@ async function executePgRestore(command) {
|
|
|
1995
1996
|
pgRestoreArgs.push('--data-only');
|
|
1996
1997
|
}
|
|
1997
1998
|
|
|
1998
|
-
//
|
|
1999
|
-
|
|
1999
|
+
// Siempre agregar --if-exists para evitar errores con DROP
|
|
2000
|
+
if (!clean_before_restore) {
|
|
2001
|
+
pgRestoreArgs.push('--if-exists');
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
// NO usar --exit-on-error por defecto - dejar que pg_restore continúe
|
|
2005
|
+
// Los errores de DROP son normales cuando el objeto no existe
|
|
2006
|
+
// pg_restore luego creará todo lo que necesita
|
|
2007
|
+
|
|
2000
2008
|
pgRestoreArgs.push('--no-owner');
|
|
2001
2009
|
pgRestoreArgs.push('--no-privileges');
|
|
2002
2010
|
|
|
@@ -2017,12 +2025,38 @@ async function executePgRestore(command) {
|
|
|
2017
2025
|
throw new Error(`Error ejecutando pg_restore: ${result.error.message}`);
|
|
2018
2026
|
}
|
|
2019
2027
|
|
|
2028
|
+
// pg_restore puede retornar exit code 1 con warnings de DROP que son normales
|
|
2029
|
+
// Verificar si es un error crítico o solo warnings
|
|
2020
2030
|
if (result.status !== 0) {
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2031
|
+
const stderr = result.stderr || '';
|
|
2032
|
+
const stdout = result.stdout || '';
|
|
2033
|
+
|
|
2034
|
+
// Errores críticos que deben fallar
|
|
2035
|
+
const criticalErrors = [
|
|
2036
|
+
'could not connect',
|
|
2037
|
+
'authentication failed',
|
|
2038
|
+
'database .* does not exist',
|
|
2039
|
+
'permission denied',
|
|
2040
|
+
'out of memory'
|
|
2041
|
+
];
|
|
2042
|
+
|
|
2043
|
+
const hasCriticalError = criticalErrors.some(pattern =>
|
|
2044
|
+
new RegExp(pattern, 'i').test(stderr) || new RegExp(pattern, 'i').test(stdout)
|
|
2045
|
+
);
|
|
2046
|
+
|
|
2047
|
+
if (hasCriticalError) {
|
|
2048
|
+
throw new Error(`pg_restore failed with critical error: ${stderr}`);
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
// Si no es crítico, es un warning (DROP de objetos inexistentes, etc)
|
|
2052
|
+
logInfo(`Restauración completada con warnings (exit code ${result.status})`);
|
|
2053
|
+
if (stderr) {
|
|
2054
|
+
logInfo(`Warnings: ${stderr.substring(0, 500)}...`);
|
|
2055
|
+
}
|
|
2056
|
+
} else {
|
|
2057
|
+
logSuccess('Restauración completada sin errores');
|
|
2023
2058
|
}
|
|
2024
2059
|
|
|
2025
|
-
logSuccess('Restauración completada');
|
|
2026
2060
|
await addCommandLog('success', 'Base de datos restaurada');
|
|
2027
2061
|
|
|
2028
2062
|
// Actualizar estado en DB
|