diff --git a/src/food-market.api/Background/ApiReferenceDocsJob.cs b/src/food-market.api/Background/ApiReferenceDocsJob.cs index fd5e79d..00a2dc9 100644 --- a/src/food-market.api/Background/ApiReferenceDocsJob.cs +++ b/src/food-market.api/Background/ApiReferenceDocsJob.cs @@ -147,7 +147,10 @@ private static IEnumerable ScanDir(string dir) .Where(s => !string.IsNullOrEmpty(s))).Trim('/'); } - var permMatch = Regex.Match(attrs, @"\[RequiresPermission\(""([^""]+)""\)\]"); + // Без обязательных внешних скобок — атрибут часто комбинируется: + // `[HttpGet, RequiresPermission("StocksView")]`. С `\[...\]` такие + // пропускались (Permission пустел). + var permMatch = Regex.Match(attrs, @"RequiresPermission\(""([^""]+)""\)"); var perm = permMatch.Success ? permMatch.Groups[1].Value : ""; var docRaw = m.Groups["doc"].Value; diff --git a/src/food-market.infrastructure/Persistence/Configurations/MoneyConfigurations.cs b/src/food-market.infrastructure/Persistence/Configurations/MoneyConfigurations.cs index fd3395b..4a1440d 100644 --- a/src/food-market.infrastructure/Persistence/Configurations/MoneyConfigurations.cs +++ b/src/food-market.infrastructure/Persistence/Configurations/MoneyConfigurations.cs @@ -85,10 +85,13 @@ public static void ConfigureMoney(this ModelBuilder b) e.HasOne(x => x.Supply).WithMany().HasForeignKey(x => x.SupplyId).OnDelete(DeleteBehavior.Restrict); e.HasOne(x => x.SupplierReturn).WithMany().HasForeignKey(x => x.SupplierReturnId).OnDelete(DeleteBehavior.Restrict); - // CHECK: ровно одна целевая ссылка должна быть заполнена. + // CHECK: ровно одна целевая ссылка должна быть заполнена. Портируемое + // выражение (CASE WHEN вместо Postgres-only `::int`) — чтобы схему можно + // было построить и на SQLite (юнит-тесты через EnsureCreated), и на + // Postgres. Семантика идентична `::int`-варианту из миграции Phase33a. e.ToTable(t => t.HasCheckConstraint( "ck_money_link_single_target", - "((\"SupplyId\" IS NOT NULL)::int + (\"SupplierReturnId\" IS NOT NULL)::int) = 1")); + "((CASE WHEN \"SupplyId\" IS NOT NULL THEN 1 ELSE 0 END) + (CASE WHEN \"SupplierReturnId\" IS NOT NULL THEN 1 ELSE 0 END)) = 1")); e.HasIndex(x => new { x.OrganizationId, x.SupplyId }) .HasFilter("\"SupplyId\" IS NOT NULL");