Files
vtuber-awards/Backend/README.md
T
2026-06-17 11:35:45 +02:00

77 lines
1.5 KiB
Markdown

# Backend
## PostgreSQL
The API targets PostgreSQL through EF Core 8 and `Npgsql.EntityFrameworkCore.PostgreSQL`.
Default local development connection string:
```text
Host=localhost;Port=5433;Database=vtuber_star_awards_dev;Username=postgres;Password=postgres
```
You can override it with:
- `Backend/appsettings.Development.json`
- environment variable `VTSA_POSTGRES`
If Docker is available locally, start a dev database from the repository root with:
```bash
docker compose -f docker-compose.dev.yml up -d
```
## Commands
Restore and build:
```bash
dotnet restore
dotnet build
```
Create a migration:
```bash
dotnet ef migrations add InitialCreate
```
Generate a SQL migration script:
```bash
dotnet ef migrations script 0 20260617060000_InitialCreate --output Migrations/InitialCreate.sql
```
Apply migrations once PostgreSQL is running:
```bash
dotnet ef database update
```
Fallback bootstrap if `dotnet ef` is not usable in the current environment:
```bash
psql "Host=localhost Port=5433 Database=vtuber_star_awards_dev Username=postgres Password=postgres" -f Migrations/InitialCreate.manual.sql
```
Run the API:
```bash
ASPNETCORE_ENVIRONMENT=Development dotnet run
```
Check the API and database wiring:
```bash
curl http://localhost:5084/api/health
curl http://localhost:5084/api/health/database
```
Development auth/session:
```bash
curl -X POST http://localhost:5084/api/auth/dev-login \
-H "Content-Type: application/json" \
-d '{"twitchUserId":"admin_demo","displayName":"Admin Demo","role":"admin"}'
```