chore: Phase 1 complète — socle technique HomeHub opérationnel

- Corrige le seed pour vérifier l'existence des tables avant insertion
  (évite l'échec au démarrage si les migrations n'ont pas encore été appliquées)
- Ajuste le port frontend de 3000 à 3001 (port 3000 occupé sur l'hôte)
- Migrations Alembic : schémas notes, shopping, todos créés avec succès
- Seed : 114 produits et 9 magasins chargés
- Endpoint /api/health : {"status":"ok"}
- Tests : 6/6 passent (health + media)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 05:30:53 +02:00
co-authored by Claude Sonnet 4.6
parent 99b9f1641e
commit 9041b24384
2 changed files with 40 additions and 20 deletions
+21 -1
View File
@@ -6,7 +6,8 @@ import asyncio
import json
from pathlib import Path
from sqlalchemy import select
from sqlalchemy import select, text
from sqlalchemy.exc import ProgrammingError
from app.core.database import AsyncSessionLocal
from app.models.shopping import Product, Store
@@ -15,7 +16,24 @@ DATA_DIR = Path(__file__).parent
async def run_seed() -> None:
try:
async with AsyncSessionLocal() as session:
# Vérifier que la table existe avant de faire le seed
try:
result = await session.execute(
text(
"SELECT COUNT(*) FROM information_schema.tables "
"WHERE table_schema = 'shopping' AND table_name = 'stores'"
)
)
table_exists = result.scalar() > 0
except Exception:
table_exists = False
if not table_exists:
print("Seed ignoré — les migrations Alembic n'ont pas encore été appliquées.")
return
count = await session.scalar(select(Store).limit(1))
if count is not None:
print("Seed déjà chargé — rien à faire.")
@@ -36,6 +54,8 @@ async def run_seed() -> None:
await session.commit()
print(f"Seed : {len(stores_raw)} magasins, {len(products_raw)} produits chargés.")
except ProgrammingError as e:
print(f"Seed ignoré — tables non disponibles (migrations requises) : {e}")
if __name__ == "__main__":
+1 -1
View File
@@ -30,7 +30,7 @@ services:
frontend:
build: ./frontend
ports:
- "3000:80"
- "3001:80"
depends_on:
- backend