mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02:00
docs: update docker setup and migration summary with PostgreSQL fixes
This commit is contained in:
parent
4b00534e53
commit
ffc3de612a
3 changed files with 101 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ Docker Compose setup để chạy Komga với PostgreSQL cho development và tes
|
|||
|
||||
## File Structure
|
||||
|
||||
### 1. docker-compose.yml
|
||||
### 1. docker-compose.yml (Production/Standard)
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
|
|
@ -55,7 +55,67 @@ volumes:
|
|||
komga_config:
|
||||
```
|
||||
|
||||
### 2. docker-compose-test.yml (cho testing)
|
||||
### 2. docker-compose.local.yml (Local Development với Build)
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: komga-postgres
|
||||
environment:
|
||||
POSTGRES_DB: komga
|
||||
POSTGRES_USER: komga
|
||||
POSTGRES_PASSWORD: komga123
|
||||
ports:
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/01-init.sql
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U komga" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
komga:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.local
|
||||
container_name: komga-backend
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: docker
|
||||
KOMGA_DATABASE_TYPE: postgresql
|
||||
KOMGA_DATABASE_URL: jdbc:postgresql://postgres:5432/komga
|
||||
KOMGA_DATABASE_USERNAME: komga
|
||||
KOMGA_DATABASE_PASSWORD: komga123
|
||||
KOMGA_CONFIG_DIR: /config
|
||||
KOMGA_DATABASE_POOL_SIZE: 10
|
||||
KOMGA_DATABASE_MAX_POOL_SIZE: 10
|
||||
SPRING_FLYWAY_ENABLED: "true"
|
||||
SPRING_FLYWAY_BASELINE_ON_MIGRATE: "true"
|
||||
SPRING_FLYWAY_BASELINE_VERSION: "20250730173126"
|
||||
ports:
|
||||
- "25600:25600"
|
||||
volumes:
|
||||
- komga_config:/config
|
||||
- ./data:/data:ro
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
komga_config:
|
||||
```
|
||||
|
||||
**Lưu ý về Dockerfile.local:**
|
||||
- Build từ source với `./gradlew :komga:prepareThymeLeaf :komga:bootJar`
|
||||
- Có thể timeout do download Gradle distribution
|
||||
- Migration fixes đã được áp dụng trong source code
|
||||
|
||||
### 3. docker-compose-test.yml (cho testing)
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
|
|
|
|||
|
|
@ -150,10 +150,48 @@ class JooqUdfHelper(
|
|||
✅ **Backend khởi động** và chạy Flyway migrations
|
||||
✅ **PostgreSQL infrastructure** đã sẵn sàng
|
||||
✅ **Docker setup** hoàn chỉnh
|
||||
✅ **Migration case sensitivity fixes** đã áp dụng
|
||||
⏳ **Integration tests** cần chạy với Testcontainers
|
||||
|
||||
## Migration Case Sensitivity Fixes (2026-04-08)
|
||||
|
||||
### Vấn đề
|
||||
PostgreSQL migrations có case sensitivity issues:
|
||||
- V001 tạo tables với quoted identifiers (`"TABLE_NAME"`) - case-sensitive
|
||||
- Older migrations reference tables without quotes (`TABLE_NAME`) - case-insensitive
|
||||
- PostgreSQL treats `"TABLE_NAME"` và `TABLE_NAME` (becomes `table_name`) là khác nhau
|
||||
|
||||
### Giải pháp đã áp dụng
|
||||
|
||||
#### 1. Fixed Java/Kotlin Migrations (5 files):
|
||||
- `V20200810154730__thumbnails_part_2.kt`: Added column check, fixed quotes
|
||||
- `V20200820150923__metadata_fields_part_2.kt`: Added column check, fixed quotes
|
||||
- `V20210624165023__missing_series_metadata.kt`: Fixed quotes
|
||||
- `V20230801104436__fix_incorrect_language_codes.kt`: Added column check, fixed quotes
|
||||
- `V20240422132621__fix_read_progress_locators.kt`: Added column check, fixed quotes
|
||||
|
||||
**Changes made:**
|
||||
- Sử dụng quoted identifiers (`"TABLE_NAME"`, `"COLUMN_NAME"`)
|
||||
- Thêm column existence checks cho migrations reference columns không có trong V001
|
||||
- Fixed result set column name access (lowercase khi dùng quoted identifiers)
|
||||
|
||||
#### 2. Created PostgreSQL SQL Migrations (2 files):
|
||||
- `V20200730135746__image_dimension.sql`: New PostgreSQL version với quoted identifiers
|
||||
- `V20220106143755__page_file_size.sql`: New PostgreSQL version với quoted identifiers
|
||||
|
||||
#### 3. V001 giữ nguyên với quoted identifiers:
|
||||
- Cần thiết cho reserved keyword `USER`
|
||||
- Tất cả tables được tạo với `"TABLE_NAME"` format
|
||||
|
||||
### Kết quả
|
||||
✅ **All 8 PostgreSQL migrations apply successfully**
|
||||
✅ **Application starts on port 25600**
|
||||
✅ **Database schema created correctly**
|
||||
✅ **Services run with docker-compose.local.yml**
|
||||
|
||||
## Lưu ý quan trọng
|
||||
- **Backward compatibility**: SQLite vẫn là default database
|
||||
- **Tasks database**: Vẫn dùng SQLite cho đơn giản
|
||||
- **Flyway**: Tự động detect vendor và sử dụng migration directory phù hợp
|
||||
- **JOOQ**: Runtime dialect dynamic, code generation vẫn dùng SQLite (Sprint 2 sẽ update)
|
||||
- **JOOQ**: Runtime dialect dynamic, code generation vẫn dùng SQLite (Sprint 2 sẽ update)
|
||||
- **Case sensitivity**: Tất cả PostgreSQL migrations giờ sử dụng quoted identifiers nhất quán với V001
|
||||
|
|
@ -13,7 +13,6 @@ services:
|
|||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/01-init.sql
|
||||
- ./komga/src/flyway/resources/db/migration/postgresql/V001__initial_migration.sql:/docker-entrypoint-initdb.d/02-schema.sql
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U komga" ]
|
||||
interval: 10s
|
||||
|
|
|
|||
Loading…
Reference in a new issue