fix(db-hardening): Add lib __init__.py and improve MinIO import error handling
This commit is contained in:
71
docs/DB_HARDENING_QUICKSTART.md
Normal file
71
docs/DB_HARDENING_QUICKSTART.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# DB Hardening Quick Start
|
||||||
|
|
||||||
|
## Швидкий старт
|
||||||
|
|
||||||
|
### 1. Запустити PostgreSQL + Backup + MinIO
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose -f docker-compose.db.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Налаштувати MinIO
|
||||||
|
|
||||||
|
1. Відкрити консоль: `http://localhost:9001`
|
||||||
|
2. Логін: `assets-admin` / пароль з `.env`
|
||||||
|
3. Створити bucket: `daarion-assets`
|
||||||
|
4. Встановити public read policy
|
||||||
|
|
||||||
|
### 3. Налаштувати ENV
|
||||||
|
|
||||||
|
Додати в `.env`:
|
||||||
|
|
||||||
|
```env
|
||||||
|
POSTGRES_PASSWORD=your-secure-password
|
||||||
|
MINIO_ROOT_USER=assets-admin
|
||||||
|
MINIO_ROOT_PASSWORD=your-secure-password
|
||||||
|
ASSETS_BUCKET=daarion-assets
|
||||||
|
ASSETS_PUBLIC_BASE_URL=https://assets.daarion.space/daarion-assets
|
||||||
|
MINIO_ENDPOINT=http://minio:9000
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Перевірити
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# PostgreSQL
|
||||||
|
docker exec daarion-postgres psql -U postgres -d daarion -c "SELECT 1;"
|
||||||
|
|
||||||
|
# MinIO
|
||||||
|
curl http://localhost:9000/minio/health/live
|
||||||
|
|
||||||
|
# Backup
|
||||||
|
ls -lh db_backups/
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Якщо база втрачена
|
||||||
|
|
||||||
|
### Швидке відновлення
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Застосувати міграції
|
||||||
|
for f in migrations/*.sql; do
|
||||||
|
docker exec -i daarion-postgres psql -U postgres -d daarion < "$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2. Seed базові дані
|
||||||
|
python3 scripts/seed_full_city_reset.py
|
||||||
|
|
||||||
|
# 3. DAGI-агенти NODE2
|
||||||
|
python3 scripts/sync-node2-dagi-agents.py
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Документація
|
||||||
|
|
||||||
|
- **DB_RESTORE.md** - відновлення з бекапу
|
||||||
|
- **SEED_RECOVERY.md** - аварійне відновлення
|
||||||
|
- **INFRA_ASSETS_MINIO.md** - налаштування MinIO
|
||||||
|
- **TASK_PHASE_DATABASE_HARDENING_AND_ASSETS_MIGRATION_v1.md** - повний таск
|
||||||
|
|
||||||
7
services/city-service/lib/__init__.py
Normal file
7
services/city-service/lib/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
"""
|
||||||
|
City Service Library
|
||||||
|
"""
|
||||||
|
from .assets_client import upload_asset, delete_asset, ensure_bucket
|
||||||
|
|
||||||
|
__all__ = ['upload_asset', 'delete_asset', 'ensure_bucket']
|
||||||
|
|
||||||
@@ -18,9 +18,9 @@ import shutil
|
|||||||
try:
|
try:
|
||||||
from lib.assets_client import upload_asset as minio_upload_asset
|
from lib.assets_client import upload_asset as minio_upload_asset
|
||||||
MINIO_AVAILABLE = True
|
MINIO_AVAILABLE = True
|
||||||
except ImportError:
|
except ImportError as e:
|
||||||
MINIO_AVAILABLE = False
|
MINIO_AVAILABLE = False
|
||||||
logger.warning("MinIO client not available, falling back to local storage")
|
logger.warning(f"MinIO client not available, falling back to local storage: {e}")
|
||||||
|
|
||||||
from models_city import (
|
from models_city import (
|
||||||
CityRoomRead,
|
CityRoomRead,
|
||||||
|
|||||||
Reference in New Issue
Block a user