feat(db): Medio + Seccion (temporal tables + seed) — ADM-001 B1
V011 crea dbo.Medio y dbo.Seccion con SYSTEM_VERSIONING ON (retention 10 anios) y PAGE compression en history; siembra el permiso 'administracion:secciones:gestionar' y lo asigna a rol admin. El permiso 'administracion:medios:gestionar' ya existia desde V005. V012 siembra Medios fundacionales ELDIA y ELPLATA (MERGE idempotente). Rollbacks V011/V012 validados estructuralmente; aplicacion y reaplicacion verificadas en SIGCM2_Test y SIGCM2. Fixture de tests actualizado: EnsureV011SchemaAsync, SeedMediosCanonicalAsync, ignora Medio_History y Seccion_History en Respawner.
This commit is contained in:
30
database/migrations/V012_ROLLBACK.sql
Normal file
30
database/migrations/V012_ROLLBACK.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- V012_ROLLBACK.sql
|
||||
-- Reversa de V012__seed_medios.sql.
|
||||
--
|
||||
-- Elimina los seed rows ELDIA y ELPLATA solo si NO tienen Secciones asociadas.
|
||||
-- Si alguna sección depende de un seed Medio, el DELETE falla por FK ON DELETE NO ACTION.
|
||||
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
SET ANSI_NULLS ON;
|
||||
SET NOCOUNT ON;
|
||||
GO
|
||||
|
||||
-- Falla temprano si hay secciones vivas apuntando a estos Medios.
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM dbo.Seccion s
|
||||
JOIN dbo.Medio m ON m.Id = s.MedioId
|
||||
WHERE m.Codigo IN ('ELDIA', 'ELPLATA')
|
||||
)
|
||||
BEGIN
|
||||
RAISERROR('Cannot rollback V012: existen Secciones vinculadas a ELDIA/ELPLATA. Rollback ADM-001 completo con V011_ROLLBACK.sql.', 16, 1);
|
||||
RETURN;
|
||||
END
|
||||
GO
|
||||
|
||||
DELETE FROM dbo.Medio
|
||||
WHERE Codigo IN ('ELDIA', 'ELPLATA');
|
||||
GO
|
||||
|
||||
PRINT 'V012 rolled back — seed Medios ELDIA y ELPLATA removed.';
|
||||
GO
|
||||
Reference in New Issue
Block a user