Docs init

This commit is contained in:
2026-05-17 17:17:04 +02:00
parent 293b6f0266
commit 22b2289933
7 changed files with 812 additions and 0 deletions

109
docs/06_infrastructure.md Normal file
View File

@@ -0,0 +1,109 @@
# Infrastructure
## MySQL Container
The MySQL 8.4 OLTP database runs in Docker (or Podman) for easy setup and teardown without requiring a local MySQL installation.
### Starting and stopping
**Linux (Docker):**
```bash
./docker/start.sh # start
./docker/stop.sh # stop (data is preserved)
```
**Linux (Podman):**
```bash
./docker/start.sh --podman
./docker/stop.sh --podman
```
**Windows (PowerShell):**
```powershell
./docker/start.ps1
./docker/stop.ps1
```
### Connection details
| Property | Value |
|---|---|
| Host | 127.0.0.1 |
| Port | **13306** (non-standard to avoid conflicts with any local MySQL) |
| Database | ewc2025 |
| User | root |
| Password | ewc2025root |
### What happens on first start
When the container is created for the first time, MySQL automatically executes any `.sql` files found in `/docker-entrypoint-initdb.d/`. The start script mounts `sql/schema.sql` there, so the database schema is created automatically — you do not need to run the DDL manually.
### Data persistence
Container data is stored in a named Docker/Podman volume (`ewc2025-mysql-data`). Stopping and restarting the container does not lose any data.
To fully reset the database (drop all data and re-create from scratch):
```bash
docker rm ewc2025-mysql
docker volume rm ewc2025-mysql-data
./docker/start.sh # fresh container, empty schema
dotnet run ./scripts/seed.cs
```
---
## Seed Script
The seed script (`scripts/seed.cs`) is a single-file **.NET 10 C# script** — no project file or solution needed.
### Requirements
- .NET 10 SDK installed
- MySQL container running
### Running it
```bash
dotnet run ./scripts/seed.cs
```
The script can be run from any directory — it walks up the directory tree to find the `data/` folder automatically.
### What it does
Reads all 10 CSV files and inserts data into MySQL in this order:
1. `game` — deduplicates game names from file 01
2. `country` — from file 08; additional countries auto-inserted as encountered
3. `point_system` — from file 09
4. `prize_pool_category` — from file 06
5. `organization` — collects all org names across files 0205, 10; enriches with file 04 details
6. `tournament` — from file 01
7. `schedule` — from file 07; matched to tournaments by game name + start date
8. `player` — from file 05
9. `medalist` — from file 02
10. `match_result` — from file 10
11. `club_championship_standing` — from file 03
12. `organization_game_competing` — from file 04 (multi-value column split)
13. `organization_game_won` — from file 03 (multi-value column split)
Expected output on a clean database:
```
Connected to MySQL.
[1/13] game
[2/13] country
...
[13/13] organization_game_won
Done. Database seeded.
```
A `WARN:` line is printed for `Battlegrounds Mobile India` (not an EWC 2025 tournament — expected and harmless).
### NuGet packages used
| Package | Purpose |
|---|---|
| `MySqlConnector 2.3.7` | MySQL database driver |
| `CsvHelper 33.0.1` | CSV parsing (handles quoted fields with commas) |
These are declared at the top of the script with `#:package` directives and restored automatically by `dotnet run`.