docs: Update documentation for 145 files

Generated by AurionDocs
Job ID: 934f8c39-8082-4942-8d17-72ed8f5f8d50
Source commit: 40aea9a
This commit is contained in:
Hue
2026-07-23 11:44:20 +02:00
parent 40aea9a04b
commit 607217b314
144 changed files with 5098 additions and 6498 deletions
@@ -8,11 +8,11 @@ public static class DatabaseSetup
```
DatabaseSetup is a startup bootstrapper that ensures the EchoHub database is ready by applying migrations, seeding a default channel, and running data migrations. It creates a scoped DbContext and logger, migrates the database, seeds a default channel when missing, and then triggers data migrations; if a legacy SQLite database is detected (no migrations history but legacy tables exist), it backs up the current file and recreates the database to enable the modern migration path.
DatabaseSetup is a startup-time orchestration helper that ensures the database is ready for use by applying migrations, seeding initial data, and performing post-migration data transformations. When you call `InitializeAsync` with an `IServiceProvider`, it creates a scoped container, resolves the required [`EchoHubDbContext`](../Data/EchoHubDbContext.cs.md) and a logger from `ILoggerFactory`, and then runs three phases: migrate the database (including legacy-handling) via `MigrateAsync`, seed the default channel via `SeedDefaultChannelAsync`, and finally invoke `DataMigrationService.RunAsync` to apply data migrations such as ANSI-to-color-tag conversions.
## Remarks
DatabaseSetup centralizes the one-time bootstrap concerns for the database, isolating migration, seeding, and legacy-handling logic from the rest of the startup flow. It relies on EF Cores migration pipeline and coordinates with DataMigrationService to perform data transformations (e.g., ANSI-to-color-tag conversions) and to ensure essential defaults (like the General channel) exist, aligning the persisted state with the application's current expectations.
DatabaseSetup centralizes the startup bootstrap workflow for the database, encapsulating migrations, schema upgrades, seeding, and legacy handling behind a single entry point. It coordinates collaborators like [`EchoHubDbContext`](../Data/EchoHubDbContext.cs.md) and [`DataMigrationService`](DataMigrationService.cs.md), and uses a scoped `IServiceProvider` so bootstrapping code does not leak scoped lifetimes to the caller. The legacy handling path ensures a clean migration story for older SQLite databases by backing up the file when a legacy schema is detected and then recreating the database with migrations support.
## Notes
- Legacy-path destructive behavior: when a legacy database is detected, the code creates a timestamped backup and then deletes the database so migrations can proceed against a fresh schema. This trade-off is intentional to enable a safe migration path from older schemas.
- Startup-time invocation: the initialization runs at application startup and establishes its own service scope; avoid multiple concurrent invocations to prevent duplicate work or conflicting migrations during a single process lifecycle.
- Legacy backup: If a legacy SQLite database is detected, the code may back up the original file to a path like `{dbPath}.legacy_{timestamp}` before deletion. This preserves a recoverable snapshot when possible.
- Startup failure: If `MigrateAsync` fails, the exception is logged and rethrown, which can cause startup to fail so the issue is addressed before the app runs.