# Task 8 Report: Применение миграций ко всем схемам тенантов **Status:** DONE (with one documented deviation in the test file — see Concerns) ## Files | File | Action | |---|---| | `src/core/Deal.Infrastructure/Migrations/TenantSchemaMigrator.cs` | Created (verbatim, plan lines 736–751) | | `src/core/tests/Deal.Tests.Unit/TenantSchemaMigratorTests.cs` | Created (test 1 verbatim; test 2 assertion repaired — see Concerns) | `TenantSchemaMigrator` is a single public static type in its own file with XML-doc from the plan. `CreateSchemaSql` uses doubled-quote identifier escaping (`Replace("\"", "\"\"")`); `ListTenantSchemasSql` is verbatim. Production code NOT modified relative to the plan. ## Build output `dotnet build Deal.sln` — succeeded: 11/11 projects, **0 warnings / 0 errors**. ## Test output `dotnet test tests/Deal.Tests.Unit --no-build` — **6 PASS / 0 FAIL** (4 existing + 2 new `TenantSchemaMigratorTests`). ## Concerns / Deviation 1. **Plan's test assertion was self-contradictory (verbatim code + verbatim test could not pass).** Plan test 2 asserted `Assert.DoesNotContain("\"b\"", sql)` for input `tenant_a"b`. With the sanctioned doubling escape the output is `CREATE SCHEMA IF NOT EXISTS "tenant_a""b"`, which necessarily *contains* the substring `"b"` (2nd quote of the escaped pair `""` → `b` → closing `"`). The assertion fails for any implementation that keeps the quote inside the identifier, and would even pass for a quote-*stripping* bug — it tests nothing. The plan's own Step 3 criterion ("expected 6 PASS") was therefore unreachable with that literal assertion. 2. **Fix applied (test-only, minimal):** replaced the broken single assertion with two meaningful ones: `Assert.Contains("\"tenant_a\"\"b\"", sql)` (quote is doubled) and `Assert.DoesNotContain("\"tenant_a\"b\"", sql)` (raw unescaped form is absent). Production code untouched. Precedent for adjusting plan tests to reality exists in plan Task 7's note. 3. First test (`CreateSchemaSql_IsEscaped`) kept verbatim and passes. 4. 1 public type = 1 file respected. `Directory.Build.props` untouched. No git operations performed. ## Verification - Build: `dotnet build Deal.sln` → «Сборка успешно выполнено», 0 warnings/errors. - Tests: `dotnet test tests/Deal.Tests.Unit --no-build` → «всего: 6; сбой: 0; успешно: 6».