feat(templates): add service language template management
Add normalized service and template catalogs, scoped administration, migration, validation, and regression coverage. Ref: IT-1601
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HrynCo.NotificationService.DAL.EF;
|
||||
|
||||
internal sealed class TemplateMutationRunner(NotificationDbContext db)
|
||||
{
|
||||
public async Task ExecuteAsync(Func<Task> write, CancellationToken ct)
|
||||
{
|
||||
await using var transaction = db.Database.CurrentTransaction is null
|
||||
? await db.Database.BeginTransactionAsync(ct) : null;
|
||||
// Service/language administration and template writes share the same transaction lock.
|
||||
// Counts, catalog membership and revision checks are therefore valid until commit.
|
||||
await db.Database.ExecuteSqlRawAsync("SELECT pg_advisory_xact_lock(1601)", ct);
|
||||
await write();
|
||||
await db.SaveChangesAsync(ct);
|
||||
if (transaction is not null)
|
||||
await transaction.CommitAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user