Portierung der beiden fehlenden Grundbausteine aus PolytraderSharp (voller Ausbau). Core S-0 (Datenfundament fuer Analyse/Forensik): - core_decision_journal + core_order_events (+ ReasonCode/Decision/OrderEvent-Enums), IDecisionJournal/IOrderEventLog mit fehlertoleranten EF-Impls (Handel bricht nie). - SignalId-Durchreichung TradeSignal -> ExecutionService -> core_trade_history; ExecutionService schreibt an jeder Verzweigung Journal/Order-Events. - JSONL-Log-Sink (LogJson + Dual-Sink), pure Analytik: RealizedPnlEngine (FIFO), TradeAnalytics, DossierBuilder. Migration AddAnalysisFoundation. Accounting-Modul (acc_): unabhaengiger IBKR-Kontoauszug (Activity Flex Query) hinter Interfaces mit Offline-Null-Stubs -> append-only Ledger + Periodenabrechnung/BWA + FX (USD/EUR) + CSV/PDF (PDFsharp/MigraDoc). Steuerschicht bewusst offen (Platzhalter-Tab). Kein Handel. Migration InitialAccounting. Supervisor-Modul (sup_): read-only OpenRouter-Agent (Function-Calling-Loop) + read-only Tool-Registry (8 Tools) + Profile + Dossier-Browser + Counterfactual-Job (Stub) + Tagesbericht/MCP-Light (opt-in). Migration InitialSupervisor. Verdrahtung: Program.cs (beide Module + Icons), slnx/App/Tests-Referenzen, provision-db.ps1, AppSettings-Sektionen, docs/konzepte, README. Tests: 79 -> 117 gruen (FIFO/KPIs/Dossier/JSONL, Classifier/Engine/FX/Idempotenz, OpenRouter/Registry/Agent/MCP, STA-Konstruktion beider neuen Fenster). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
57 lines
2.8 KiB
PowerShell
57 lines
2.8 KiB
PowerShell
<#
|
||
IBKRTrader – DB-Provisioning.
|
||
|
||
Wendet die EF-Core-Migrationen beider Contexts (Core + CongressTrading) auf die Ziel-DB an.
|
||
Der Connection-String wird aus appsettings.Local.json gelesen und als Umgebungsvariable
|
||
IBKRTRADER_MYSQL an die Design-Time-Factories weitergereicht.
|
||
|
||
WICHTIG: Falls von frueheren Laeufen noch alte (snake_case) Tabellen in der DB liegen, vorher
|
||
einmalig scripts/drop-app-tables.sql ausfuehren – sonst schlaegt 'database update' fehl
|
||
(Table already exists).
|
||
|
||
Aufruf (aus dem Projekt-Root):
|
||
powershell -ExecutionPolicy Bypass -File scripts/provision-db.ps1
|
||
#>
|
||
|
||
$ErrorActionPreference = 'Stop'
|
||
$root = Split-Path -Parent $PSScriptRoot
|
||
|
||
# 1. Connection-String aus appsettings.Local.json lesen.
|
||
$localPath = Join-Path $root 'appsettings.Local.json'
|
||
if (-not (Test-Path $localPath)) {
|
||
Write-Error "appsettings.Local.json nicht gefunden ($localPath). Datei mit Database:MySqlConnectionString anlegen."
|
||
exit 1
|
||
}
|
||
$conn = (Get-Content $localPath -Raw | ConvertFrom-Json).Database.MySqlConnectionString
|
||
if ([string]::IsNullOrWhiteSpace($conn)) {
|
||
Write-Error "Database:MySqlConnectionString in appsettings.Local.json ist leer."
|
||
exit 1
|
||
}
|
||
$env:IBKRTRADER_MYSQL = $conn
|
||
Write-Host "Connection aus appsettings.Local.json geladen." -ForegroundColor Green
|
||
|
||
# 2. dotnet-ef vorhanden?
|
||
try { dotnet ef --version | Out-Null } catch {
|
||
Write-Error "dotnet-ef fehlt. Installieren mit: dotnet tool install --global dotnet-ef"
|
||
exit 1
|
||
}
|
||
|
||
# 3. Migrationen anwenden – Core, dann Modul.
|
||
Write-Host "Wende CoreDbContext-Migrationen an..." -ForegroundColor Cyan
|
||
dotnet ef database update --project src/IBKRTrader.Core --startup-project src/IBKRTrader.Core --context CoreDbContext
|
||
if ($LASTEXITCODE -ne 0) { Write-Error "CoreDbContext-Migration fehlgeschlagen."; exit 1 }
|
||
|
||
Write-Host "Wende CongressTradingDbContext-Migrationen an..." -ForegroundColor Cyan
|
||
dotnet ef database update --project src/IBKRTrader.Modules.CongressTrading --startup-project src/IBKRTrader.Modules.CongressTrading --context CongressTradingDbContext
|
||
if ($LASTEXITCODE -ne 0) { Write-Error "CongressTradingDbContext-Migration fehlgeschlagen."; exit 1 }
|
||
|
||
Write-Host "Wende AccountingDbContext-Migrationen an..." -ForegroundColor Cyan
|
||
dotnet ef database update --project src/IBKRTrader.Modules.Accounting --startup-project src/IBKRTrader.Modules.Accounting --context AccountingDbContext
|
||
if ($LASTEXITCODE -ne 0) { Write-Error "AccountingDbContext-Migration fehlgeschlagen."; exit 1 }
|
||
|
||
Write-Host "Wende SupervisorDbContext-Migrationen an..." -ForegroundColor Cyan
|
||
dotnet ef database update --project src/IBKRTrader.Modules.Supervisor --startup-project src/IBKRTrader.Modules.Supervisor --context SupervisorDbContext
|
||
if ($LASTEXITCODE -ne 0) { Write-Error "SupervisorDbContext-Migration fehlgeschlagen."; exit 1 }
|
||
|
||
Write-Host "DB-Provisioning abgeschlossen." -ForegroundColor Green
|