chore(udt-011): SqlTestFixture.EnsureV015SchemaAsync for timezone views
This commit is contained in:
@@ -47,6 +47,9 @@ public sealed class SqlTestFixture : IAsyncLifetime
|
||||
// V014 (ADM-009): ensure dbo.TipoDeIva + dbo.IngresosBrutos + temporal + seed + permiso fiscal.
|
||||
await EnsureV014SchemaAsync();
|
||||
|
||||
// V015 (UDT-011): ensure dbo.v_AuditEvent_Local + dbo.v_SecurityEvent_Local views exist.
|
||||
await EnsureV015SchemaAsync();
|
||||
|
||||
_respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
|
||||
{
|
||||
DbAdapter = DbAdapter.SqlServer,
|
||||
@@ -774,4 +777,62 @@ public sealed class SqlTestFixture : IAsyncLifetime
|
||||
// Permiso 'administracion:fiscal:gestionar' y asignacion a admin se siembran
|
||||
// desde SeedPermisosCanonicalAsync / SeedRolPermisosCanonicalAsync (post-respawn).
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UDT-011 (V015): applies dbo.v_AuditEvent_Local + dbo.v_SecurityEvent_Local views
|
||||
/// idempotently to the test database. Mirrors V015__create_local_timezone_views.sql.
|
||||
/// Views expose OccurredAtLocal (DateTimeOffset, offset -03:00 Argentina Standard Time).
|
||||
/// Note: CREATE VIEW cannot be inside IF...BEGIN...END directly — uses EXEC('CREATE VIEW ...').
|
||||
/// </summary>
|
||||
private async Task EnsureV015SchemaAsync()
|
||||
{
|
||||
const string createAuditEventLocal = """
|
||||
IF OBJECT_ID('dbo.v_AuditEvent_Local', 'V') IS NULL
|
||||
BEGIN
|
||||
EXEC('
|
||||
CREATE VIEW dbo.v_AuditEvent_Local AS
|
||||
SELECT
|
||||
Id,
|
||||
OccurredAt,
|
||||
OccurredAt AT TIME ZONE ''UTC'' AT TIME ZONE ''Argentina Standard Time'' AS OccurredAtLocal,
|
||||
ActorUserId,
|
||||
ActorRoleId,
|
||||
Action,
|
||||
TargetType,
|
||||
TargetId,
|
||||
CorrelationId,
|
||||
IpAddress,
|
||||
UserAgent,
|
||||
Metadata
|
||||
FROM dbo.AuditEvent;
|
||||
');
|
||||
END
|
||||
""";
|
||||
|
||||
const string createSecurityEventLocal = """
|
||||
IF OBJECT_ID('dbo.v_SecurityEvent_Local', 'V') IS NULL
|
||||
BEGIN
|
||||
EXEC('
|
||||
CREATE VIEW dbo.v_SecurityEvent_Local AS
|
||||
SELECT
|
||||
Id,
|
||||
OccurredAt,
|
||||
OccurredAt AT TIME ZONE ''UTC'' AT TIME ZONE ''Argentina Standard Time'' AS OccurredAtLocal,
|
||||
ActorUserId,
|
||||
AttemptedUsername,
|
||||
SessionId,
|
||||
Action,
|
||||
Result,
|
||||
FailureReason,
|
||||
IpAddress,
|
||||
UserAgent,
|
||||
Metadata
|
||||
FROM dbo.SecurityEvent;
|
||||
');
|
||||
END
|
||||
""";
|
||||
|
||||
await _connection.ExecuteAsync(createAuditEventLocal);
|
||||
await _connection.ExecuteAsync(createSecurityEventLocal);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user