# 20260513183726_FixKnowledgeUnitEbookId

- File ID: file:1r47ykv:20260513183726-fixknowledgeunitebookid-cs
- Path: NexusReader.Data/Persistence/Migrations/20260513183726_FixKnowledgeUnitEbookId.cs
- Role: database-config
- Layer: data

## Purpose

EF Core migration that replaces KnowledgeUnits.SourceId (string) with KnowledgeUnits.EbookId (Guid), adds index and FK to Ebooks, and provides the reverse Down migration.

## Key Details

Up adds a non-nullable Guid EbookId with default Guid.Empty, index, and FK to Ebooks (cascade delete). Down restores previous SourceId string column (varchar(128)) and its index.

## Symbols

- FixKnowledgeUnitEbookId: EF Core migration that replaces KnowledgeUnits.SourceId (string) with KnowledgeUnits.EbookId (Guid), adds index and FK to Ebooks, and provides the reverse Down migration.
- Up(): Apply schema changes: remove SourceId column and index from KnowledgeUnits, add non-nullable EbookId Guid column with default, create index on EbookId, and add FK to Ebooks with cascade delete.
- Down(): Revert schema changes applied in Up: remove FK and index on EbookId, drop EbookId column, re-add SourceId string column with constraints and recreate its index.
- FixKnowledgeUnitEbookId: EF Core Migration class that applies and reverts schema changes to replace SourceId with EbookId on KnowledgeUnits.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Coverage

- Symbols: 4
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 4
- Unresolved references: 0
- Control-flow fragments: 2
- Unresolved jumps: 0
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 2

## Control Flow Fragments

- Up: 7 nodes, 6 edges, 0 jumps, 0 unsupported constructs
- Down: 7 nodes, 6 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### 20260513183726_FixKnowledgeUnitEbookId Neighborhood

```mermaid
flowchart LR
    class_1jh8uof_fixknowledgeunitebookid("FixKnowledgeUnitEbookId")
    file_1r47ykv_20260513183726_fixknowledgeunitebookid_cs("20260513183726_FixKnowledgeUnitEbookId")
    method_1ste7vn_down[["Down()"]]
    method_cdxwj_up[["Up()"]]
    type_1a7gg4i_fixknowledgeunitebookid[/"FixKnowledgeUnitEbookId"/]
```

### 20260513183726_FixKnowledgeUnitEbookId Execution Overview

```mermaid
flowchart TD
    class_1jh8uof_fixknowledgeunitebookid("FixKnowledgeUnitEbookId")
    method_1ste7vn_down[["Down()"]]
    method_cdxwj_up[["Up()"]]
    class_1jh8uof_fixknowledgeunitebookid -->|contains| method_1ste7vn_down
    class_1jh8uof_fixknowledgeunitebookid -->|contains| method_cdxwj_up
```

## Diagram Validation

- Status: pass
