fix: release QA hardening across processing, media, security, and CI gates (#649)

A release-readiness QA pass over the whole product. The commits split into
defects a user would hit and gates that were reporting green while measuring
nothing.

## Fixes that change behaviour

Rate limiting was bypassable on every install: TRUST_PROXY defaulted to true, so
request.ip came from a client-set header and a forged X-Forwarded-For got past
the login limiter. The default is now a private-network trust list.

A transient Postgres outage stranded in-flight jobs, leaving finished output on
disk with no row pointing at it. A reconciler now resolves those rows and adopts
the bytes rather than dropping the work.

A Redis connection that moved to a new address wedged every read-blocked
consumer, so completions stopped signalling while health still answered 200.
Socket timeouts plus subscriber pings recover it.

Installing more than one AI bundle left the shared venv multi-versioned and
silently broke three tools. The installer now reconciles distributions to one
version each.

Converting an image to JXL at quality 1 through 4 returned a 500, because
libjxl 0.7 rejects the distance those values compute. The quality is floored at
what the encoder honours. A missing ffmpeg was also reported to the user as a
corrupt upload; it now says the engine is unavailable.

RAW uploads reached an unpatched LibRaw on arm64, so it is built from source at
0.22.2, and the release scan was split so it can fail on an unfixed critical
instead of hiding it behind ignore-unfixed.

## Gates that could not fail

Two mutation lanes ran zero mutants because Stryker crawled the gitignored docs
build; coverage discarded its whole report on any failing test; the lint gate
skipped root tests, scripts, and two workspaces; and several generated matrices
counted a host missing ffmpeg as a passing tool. Each now measures what it
claims.

Full evidence and the outstanding release items are tracked locally and are not
part of this branch.
This commit is contained in:
SnapOtter
2026-07-27 15:37:30 +08:00
committed by GitHub
parent bc32f86a07
commit d10d0f544f
855 changed files with 54564 additions and 13092 deletions
+35 -15
View File
@@ -1,8 +1,9 @@
---
description: "SnapOtter의 PostgreSQL 데이터베이스 스키마, 테이블, 마이그레이션, 백업 절차."
i18n_source_hash: 50d5d4f220cf
i18n_provenance: human
i18n_output_hash: 4616baed29d0
i18n_source_hash: a68264552836
i18n_provenance: machine
i18n_output_hash: 469f8d270e1f
i18n_hash_version: 2
---
# 데이터베이스 {#database}
@@ -145,6 +146,17 @@ SnapOtter는 데이터 영속성을 위해 PostgreSQL 17과 [Drizzle ORM](https:
| `details` | jsonb | 작업별 데이터 |
| `createdAt` | timestamp | 작업 시각 |
### user_preferences {#user-preferences}
사용자별 UI 상태를 환경설정 이름으로 키를 잡아 저장합니다. 홈페이지에 고정된 도구는 `PUT /api/v1/preferences`를 통해 여기에 기록됩니다.
| 컬럼 | 타입 | 비고 |
|---|---|---|
| `userId` | text | users에 대한 FK, 삭제 시 연쇄 적용. `key`와 함께 기본 키 |
| `key` | text | 환경설정 이름. `userId`와 함께 기본 키 |
| `value` | jsonb | 환경설정 내용 |
| `updatedAt` | timestamp | 마지막 쓰기 시각 |
## 마이그레이션 {#migrations}
Drizzle이 스키마 마이그레이션을 처리합니다. 마이그레이션 파일은 `apps/api/drizzle/`에 있습니다. 개발 중에는:
@@ -157,29 +169,37 @@ npx drizzle-kit migrate # apply pending migrations
프로덕션에서는 시작 시 대기 중인 마이그레이션이 자동으로 적용됩니다.
## 백업 및 복원 {#backup-and-restore}
## {#backup-and-restore} 백업 및 복원
관계형 데이터베이스는 앱의 `/data` 볼륨이 아니라 Postgres 컨테이너의 `SnapOtter-pgdata` 볼륨에 있습니다.
관계형 데이터베이스는 앱의 `/data` 볼륨이 아 Postgres 컨테이너의 `SnapOtter-pgdata` 볼륨에 있습니다.
**옵션 1: pg_dump (권장)**
**검증을 통한 논리적 백업(권장)**
```bash
# Dump the database while the stack is running
docker exec SnapOtter-postgres pg_dump -U snapotter snapotter > backup.sql
# Dump into PostgreSQL's portable custom archive format
docker exec SnapOtter-postgres \
pg_dump --format=custom --no-owner -U snapotter snapotter > snapotter.dump
test -s snapotter.dump
docker exec -i SnapOtter-postgres pg_restore --list < snapotter.dump >/dev/null
# Restore into a fresh database
cat backup.sql | docker exec -i SnapOtter-postgres psql -U snapotter snapotter
# Restore into a fresh/disposable target first and fail on the first SQL error
docker exec -i SnapOtter-postgres \
pg_restore --exit-on-error --clean --if-exists --no-owner \
-U snapotter -d snapotter < snapotter.dump
```
**옵션 2: 볼륨 스냅샷**
이 데이터베이스 덤프에는 Redis의 `/data/files` 또는 내구성 있는 BullMQ 상태에 저장된 라이브러리 개체가 포함되어 있지 않습니다. [보안 및 강화](/ko/guide/security#backup-and-recovery)의 조정된 절차에 따라 백업 및 복원하세요.
**콜드 볼륨 스냅샷**
```bash
# Stop the stack, then snapshot the pgdata volume
docker compose down
docker run --rm -v SnapOtter-pgdata:/data -v $(pwd)/backup:/backup \
alpine tar czf /backup/snapotter-pgdata.tar.gz -C /data .
# Stop every service first, then use your storage platform to snapshot the
# PostgreSQL, app-data, and Redis volumes as one crash-consistent set.
docker compose -f docker/docker-compose.yml stop
```
`tar`를 사용하여 라이브 PostgreSQL 데이터 디렉터리를 복사하지 마세요. 프로젝트별로 접두사 볼륨 이름을 구성하므로 리터럴 레이블 `SnapOtter-pgdata`를 가정하는 대신 `docker inspect` 또는 스토리지 플랫폼에서 마운트된 볼륨 ID를 확인합니다.
### 1.x(SQLite)에서 마이그레이션 {#migrating-from-1-x-sqlite}
SnapOtter 1.x에서 업그레이드하는 방법은 별도의 가이드가 있습니다. [1.x에서 2.0으로 업그레이드](./upgrading)를 참고하세요. 간단히 말하면, 기존 `/data` 볼륨을 재사용하면 2.0이 첫 부팅 시 `/data/snapotter.db`를 자동으로 감지하고 가져옵니다(또는 `SQLITE_MIGRATE_PATH`를 설정해 명시적으로 지정할 수 있습니다). 먼저 `snapotter.db`만이 아니라 전체 `/data` 볼륨을 백업하세요. 1.x는 SQLite WAL 모드를 사용하므로, 중지된 컨테이너는 거의 비어 있는 `snapotter.db` 옆에 있는 `snapotter.db-wal`에 대부분의 데이터를 남겨두는 경우가 많습니다.