fix(nexxa): cli_estado migrar se niega con el motor pg ya activo (no pisa el estado vivo con archivos viejos); 1.7.2 (P335/F17)
Tests ADN / test (push) Canceled after 0s
Tests ADN / test (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GEMMA <noreply@gemma.dtic>
This commit is contained in:
co-authored by
Claude Opus 5.5
GEMMA
parent
43984639fa
commit
529360b98e
@@ -1 +1 @@
|
||||
1.7.1
|
||||
1.7.2
|
||||
|
||||
@@ -20,6 +20,8 @@ module Nexxa
|
||||
module CliEstado
|
||||
E = Nexxa::Estado
|
||||
USO = 'ruby cli_estado.rb esquema|migrar|verificar|exportar'
|
||||
# El drop-in que activa el motor pg en los servicios (lo escribe nexxa estado:pg --accion activar)
|
||||
DROPIN = '/etc/systemd/system/nexxa.service.d/estado.conf'
|
||||
|
||||
module_function
|
||||
|
||||
@@ -38,7 +40,19 @@ module Nexxa
|
||||
end
|
||||
end
|
||||
|
||||
def migrar(salida)
|
||||
# Con el motor pg ya activo, los archivos quedaron viejos: migrar pisaría el estado vivo con ellos. Se niega (repetir
|
||||
# 'activar' es seguro: frena acá y el trap vuelve a arrancar los servicios como estaban).
|
||||
def pg_activo?(dropin = DROPIN)
|
||||
File.exist?(dropin) && File.read(dropin).include?('NEXXA_ESTADO=pg')
|
||||
end
|
||||
|
||||
def migrar(salida, dropin: DROPIN)
|
||||
if pg_activo?(dropin)
|
||||
salida.puts("❌ el motor pg ya está activo (#{dropin}): migrar pisaría el estado vivo con archivos viejos. " \
|
||||
'Para volver a archivos: exportar (nexxa estado:pg --accion revertir)')
|
||||
return 1
|
||||
end
|
||||
|
||||
E.crear_esquema!
|
||||
dif = diferencias
|
||||
if dif.values.none?
|
||||
|
||||
@@ -212,6 +212,17 @@ class CliEstadoTest < Minitest::Test
|
||||
assert_equal 1, Dir[File.join(DIR_ESTADO, 'bkp_estado_*.tgz')].size, 'la segunda corrida no respalda ni escribe'
|
||||
end
|
||||
|
||||
def test_migrar_se_niega_con_el_motor_pg_ya_activo
|
||||
dropin = File.join(DIR_ESTADO, 'estado.conf')
|
||||
File.write(dropin, "[Service]\nEnvironment=NEXXA_ESTADO=pg\n")
|
||||
out = StringIO.new
|
||||
assert_equal 1, C.migrar(out, dropin: dropin)
|
||||
assert_match(/ya está activo/, out.string)
|
||||
assert_nil E.pg_leer('registro', nil), 'no escribió nada'
|
||||
ensure
|
||||
FileUtils.rm_f(dropin)
|
||||
end
|
||||
|
||||
def test_verificar_detecta_una_diferencia
|
||||
corre('migrar')
|
||||
E.archivo_guardar(E.ruta('pools'), { 'individuos' => { 'gemma' => { 'mente' => ['p/k1'] } } })
|
||||
|
||||
Reference in New Issue
Block a user