feat(infra): V009 migration + Usuario.WithPermisosJson + SqlTestFixture V009 schema [UDT-009]

This commit is contained in:
2026-04-15 21:27:29 -03:00
parent da1eb83ac1
commit 54955231bf
4 changed files with 370 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ public sealed class Usuario
/// <summary>
/// Factory for creating a new user (no Id — DB assigns via IDENTITY).
/// Defaults: Activo=true, PermisosJson="[]", MustChangePassword=false.
/// Defaults: Activo=true, PermisosJson={"grant":[],"deny":[]}, MustChangePassword=false.
/// </summary>
public static Usuario ForCreation(
string username,
@@ -65,7 +65,7 @@ public sealed class Usuario
apellido: apellido,
email: email,
rol: rol,
permisosJson: "[]",
permisosJson: """{"grant":[],"deny":[]}""",
activo: true,
fechaModificacion: null,
ultimoLogin: null,
@@ -131,6 +131,26 @@ public sealed class Usuario
ultimoLogin: UltimoLogin,
mustChangePassword: value);
/// <summary>
/// UDT-009: Returns a new instance with PermisosJson replaced.
/// Sets FechaModificacion = UtcNow.
/// Accepts raw JSON string so Domain stays free of Application dependencies.
/// </summary>
public Usuario WithPermisosJson(string permisosJson)
=> new(
id: Id,
username: Username,
passwordHash: PasswordHash,
nombre: Nombre,
apellido: Apellido,
email: Email,
rol: Rol,
permisosJson: permisosJson,
activo: Activo,
fechaModificacion: DateTime.UtcNow,
ultimoLogin: UltimoLogin,
mustChangePassword: MustChangePassword);
/// <summary>
/// Returns a new instance with only UltimoLogin updated.
/// Does NOT touch FechaModificacion.