# 20260503175906_FinalNormalizedSubscriptionArchitecture

- File ID: file:18pke7q:20260503175906-finalnormalizedsubscriptionarchit
- Path: NexusReader.Data/Migrations/20260503175906_FinalNormalizedSubscriptionArchitecture.cs
- Role: database-config
- Layer: data

## Purpose

EF Core migration that alters database schema to introduce normalized subscription plans, tenant scoping, vector columns (pgvector), and related knowledge unit tables; also seeds subscription plan rows.

## Key Details

Adds pgvector extension usage and vector columns (1536 and 768 dims), migrates several dates to timestamptz, normalizes subscriptions into a SubscriptionPlans table seeded with Free/Basic/Pro/Enterprise, introduces tenant scoping columns across multiple tables and creates knowledge unit/link tables with FK constraints.

## Symbols

- FinalNormalizedSubscriptionArchitecture: EF Core migration that alters database schema to introduce normalized subscription plans, tenant scoping, vector columns (pgvector), and related knowledge unit tables; also seeds subscription plan rows.
- Up(): Apply schema changes: remove/alter columns, add tenant and vector columns, create KnowledgeUnits/SubscriptionPlans/KnowledgeUnitLinks tables, seed SubscriptionPlans, create indexes and add foreign key.
- Down(): Revert schema changes performed in Up: drop created tables, indexes, columns and restore previous column types/values and the dropped CurrentPlan column.
- KnowledgeUnits (table): Stores normalized knowledge unit records with tenant scoping and vector embedding for semantic search.
- SubscriptionPlans (table): Represents normalized subscription plans with token limits, pricing and Stripe product mapping.
- KnowledgeUnitLinks (table): Associative links between knowledge units to model relations; enforces FK constraints to KnowledgeUnits.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Coverage

- Symbols: 6
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 6
- 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: 24 nodes, 23 edges, 0 jumps, 0 unsupported constructs
- Down: 12 nodes, 11 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### 20260503175906_FinalNormalizedSubscriptionArchitecture Neighborhood

```mermaid
flowchart LR
    class_tkzvf7_finalnormalizedsubscriptionarchitecture("FinalNormalizedSubscriptionArchitecture")
    file_18pke7q_20260503175906_finalnormalizedsubscriptionarchit("20260503175906_FinalNormalizedSubscriptionArchitecture")
    method_1b2dxzu_up[["Up()"]]
    method_llsrxk_down[["Down()"]]
    type_11syh06_subscriptionplans_table[/"SubscriptionPlans (table)"/]
    type_19jp6ev_knowledgeunits_table[/"KnowledgeUnits (table)"/]
    type_1pi9458_knowledgeunitlinks_table[/"KnowledgeUnitLinks (table)"/]
```

### 20260503175906_FinalNormalizedSubscriptionArchitecture Execution Overview

```mermaid
flowchart TD
    class_tkzvf7_finalnormalizedsubscriptionarchitecture("FinalNormalizedSubscriptionArchitecture")
    method_1b2dxzu_up[["Up()"]]
    method_llsrxk_down[["Down()"]]
    class_tkzvf7_finalnormalizedsubscriptionarchitecture -->|contains| method_1b2dxzu_up
    class_tkzvf7_finalnormalizedsubscriptionarchitecture -->|contains| method_llsrxk_down
```

## Diagram Validation

- Status: pass
