Merge pull request #175 from R0m1k3/1.1

1.1
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-16 13:53:36 +02:00
commit 2bacf463f9
11 files changed
+634 -2

No files matched your search

+10 -1
View File
@@ -81,6 +81,9 @@ RUN npm ci --only=production && npm cache clean --force
COPY --from=build --chown=nextjs:nodejs /app/dist ./dist
COPY --from=build --chown=nextjs:nodejs /app/shared ./shared
# Copy migration scripts
COPY --chown=nextjs:nodejs scripts/ ./scripts/
# Create symlink for public files to be accessible from dist
RUN ln -sf /app/dist/public /app/dist/public
@@ -103,5 +106,11 @@ USER nextjs
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
# Start the application
# Copy and set entrypoint script
COPY --chown=nextjs:nodejs scripts/docker-entrypoint.sh ./
RUN chmod +x /app/scripts/auto-migrate-production.sh && \
chmod +x /app/docker-entrypoint.sh
# Start the application with migration
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["node", "dist/index.js"]
+108
View File
@@ -0,0 +1,108 @@
# 🚀 Instructions de Déploiement avec Migration Automatique
## Vue d'ensemble
Le système est maintenant configuré pour exécuter automatiquement les migrations de base de données lors de chaque mise à jour Docker, garantissant que toutes les tables nécessaires sont créées.
## 🔧 Configuration Automatique
### Scripts créés
1. **`scripts/auto-migrate-production.sh`** - Migration automatique au démarrage
2. **`scripts/docker-entrypoint.sh`** - Point d'entrée avec migration
3. **`scripts/manual-migrate.sh`** - Migration manuelle si nécessaire
### Dockerfile modifié
- Copie automatique des scripts de migration
- Point d'entrée personnalisé avec migration
- Permissions configurées automatiquement
## 🚀 Déploiement
### Option 1: Reconstruction complète (Recommandée)
```bash
# Arrêter le conteneur actuel
docker-compose down
# Reconstruire avec les nouveaux scripts
docker-compose up --build -d
# Vérifier les logs de migration
docker-compose logs -f
```
### Option 2: Mise à jour sans reconstruction
```bash
# Copier les scripts dans le conteneur existant
docker cp scripts/ logiflow-logiflow-1:/app/
# Exécuter la migration manuellement
docker exec logiflow-logiflow-1 chmod +x /app/scripts/auto-migrate-production.sh
docker exec logiflow-logiflow-1 /app/scripts/auto-migrate-production.sh
# Redémarrer l'application
docker-compose restart
```
## 🔍 Vérification
### Logs de migration
```bash
# Voir les logs de migration au démarrage
docker-compose logs | grep "AUTO-MIGRATE"
```
### État des tables
```bash
# Vérifier que toutes les tables existent
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "
SELECT tablename
FROM pg_tables
WHERE schemaname = 'public'
ORDER BY tablename;
"
```
### Test du système d'annonces
```bash
# Vérifier la table announcements spécifiquement
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "
SELECT 'announcements' as table_name, count(*) as columns
FROM information_schema.columns
WHERE table_name = 'announcements';
"
```
## 🛠️ Dépannage
### Migration manuelle forcée
```bash
# Si la migration automatique échoue
docker exec logiflow-logiflow-1 /app/scripts/manual-migrate.sh
```
### Vérification des permissions
```bash
# Vérifier que les scripts sont exécutables
docker exec logiflow-logiflow-1 ls -la /app/scripts/
```
### Logs détaillés
```bash
# Activer le debug des migrations
docker-compose up -d --env DEBUG_MIGRATIONS=true
```
## 📋 Table créée automatiquement
✅ **announcements** - Système d'informations
Le script vérifie et crée **UNIQUEMENT** la table `announcements` si elle n'existe pas. Toutes les autres tables existent déjà en production et ne sont pas touchées.
## 🔄 Futures mises à jour
Désormais, chaque fois que vous mettez à jour votre application Docker :
1. Le conteneur démarre
2. La migration automatique s'exécute
3. Toutes les nouvelles tables sont créées
4. L'application démarre normalement
**Plus besoin d'intervention manuelle !**
+78
View File
@@ -0,0 +1,78 @@
# 🚨 SOLUTION IMMÉDIATE POUR LA PRODUCTION
## 🎯 Objectif
Créer **UNIQUEMENT** la table `announcements` manquante. Toutes les autres tables existent déjà en production et ne doivent pas être touchées.
## Problème
La table `announcements` n'existe pas dans votre base de données de production, ce qui cause l'erreur:
```
Error: relation "announcements" does not exist
```
## Solution en 3 étapes simples
### 1. Connectez-vous à votre serveur de production
```bash
# SSH vers votre serveur
ssh votre-serveur-production
```
### 2. Accédez au conteneur Docker
```bash
# Entrer dans le conteneur
docker exec -it logiflow-logiflow-1 bash
```
### 3. Créer la table directement
```bash
# Dans le conteneur, exécuter cette commande :
psql $DATABASE_URL -c "
CREATE TABLE IF NOT EXISTS announcements (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL,
group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')),
CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority);
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_announcements_author_id ON announcements(author_id);
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
"
```
### 4. Vérifier que ça fonctionne
```bash
# Vérifier que la table existe
psql $DATABASE_URL -c "SELECT 'SUCCESS: Table announcements créée!' as status;"
```
### 5. Sortir du conteneur
```bash
exit
```
## Résultat attendu
Après ces étapes, le système d'annonces fonctionnera immédiatement sur votre production.
## Alternative plus simple (une seule commande)
```bash
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "CREATE TABLE IF NOT EXISTS announcements (id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, priority VARCHAR(20) NOT NULL DEFAULT 'normal', author_id VARCHAR(255) NOT NULL, group_id INTEGER, created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')), CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE, CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE);"
```
## Script minimal (nouvelle option)
```bash
# Copier et exécuter le script minimal
docker cp scripts/fix-announcements-only.sh logiflow-logiflow-1:/app/scripts/
docker exec logiflow-logiflow-1 chmod +x /app/scripts/fix-announcements-only.sh
docker exec logiflow-logiflow-1 /app/scripts/fix-announcements-only.sh
```
La correction du problème `Select.Item` value est déjà faite dans le code source.
@@ -0,0 +1,242 @@
Host
Administration
User-related
Environment-related
Registries
Logs
Notifications
Settings
New version available 2.27.9
DismissSee what's new
Community Edition
2.27.6 LTS
Containers>logiflow-logiflow-1>Logs
Container logs
admin
Log viewer settings
Auto-refresh logs
Wrap lines
Display timestamps
Fetch
All logs
Search
Filter...
Lines
100
Actions
GET /api/customer-orders 200 in 830ms
GET /api/publicities 200 in 825ms
GET /api/tasks 200 in 814ms
🌤️ [RESPONSE] Weather data prepared: {
hasCurrentYear: true,
hasPreviousYear: true,
location: 'Frouard, France'
}
GET /api/weather/current 200 in 883ms
GET /api/dlc-products/stats 200 in 843ms
Orders API called with: {
startDate: undefined,
endDate: undefined,
storeId: '1',
userRole: 'admin'
}
Admin filtering with groupIds: [ 1 ]
Fetching all orders
Deliveries API called with: {
startDate: undefined,
endDate: undefined,
storeId: '1',
withBL: undefined,
userRole: 'admin'
}
Admin filtering deliveries with groupIds: [ 1 ]
Fetching all deliveries
GET /api/groups 200 in 464ms
Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' }
📊 Statistiques calculées: {
ordersCount: 20,
deliveriesCount: 42,
pendingOrdersCount: 8,
averageDeliveryTime: 0.3611111111111111,
totalPalettes: 120,
totalPackages: 36
}
GET /api/stats/monthly 200 in 937ms
🔗 PRODUCTION: getDeliveries() récupéré 86 livraisons avec relations
Deliveries returned: 86 items
GET /api/deliveries 200 in 1014ms
🔗 PRODUCTION: getOrders() récupéré 33 commandes avec relations
Orders returned: 33 items
GET /api/orders 200 in 557ms
Customer Orders returned: 10 items
GET /api/customer-orders 200 in 197ms
🔗 PRODUCTION: getDeliveries() récupéré 48 livraisons avec relations
Deliveries returned: 48 items
GET /api/deliveries 200 in 237ms
GET /api/publicities 200 in 206ms
Error fetching announcements: error: relation "announcements" does not exist
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22
at async DatabaseStorage.getAnnouncements (file:///app/dist/index.js:2074:25)
at async file:///app/dist/index.js:7420:30 {
length: 113,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '829',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '1392',
routine: 'parserOpenTable'
}
GET /api/announcements 500 in 7ms
Error fetching announcements: error: relation "announcements" does not exist
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22
at async DatabaseStorage.getAnnouncements (file:///app/dist/index.js:2074:25)
at async file:///app/dist/index.js:7420:30 {
length: 113,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '829',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '1392',
routine: 'parserOpenTable'
}
GET /api/announcements 500 in 20ms
+15
View File
@@ -0,0 +1,15 @@
# Fichier de configuration Docker Compose pour le développement et la production
# Utilise les variables d'environnement pour la configuration
version: '3.8'
services:
app:
volumes:
# Monter les scripts de migration
- ./scripts:/app/scripts:ro
environment:
# Forcer l'exécution des migrations au démarrage
- AUTO_MIGRATE=true
# Variables de debug
- DEBUG_MIGRATIONS=true
+42
View File
@@ -0,0 +1,42 @@
-- Commandes à exécuter DIRECTEMENT dans votre conteneur Docker
-- Copiez et collez ces commandes une par une dans votre terminal
-- 1. Entrer dans le conteneur
-- docker exec -it logiflow-logiflow-1 /bin/bash
-- 2. Une fois dans le conteneur, exécuter cette commande SQL :
-- psql $DATABASE_URL
-- 3. Coller ce SQL dans psql :
CREATE TABLE IF NOT EXISTS announcements (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL,
group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
ALTER TABLE announcements ADD CONSTRAINT announcements_priority_check
CHECK (priority IN ('normal', 'important', 'urgent'));
ALTER TABLE announcements ADD CONSTRAINT announcements_author_id_fkey
FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE announcements ADD CONSTRAINT announcements_group_id_fkey
FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE;
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority);
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_announcements_author_id ON announcements(author_id);
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
-- Vérification
SELECT 'SUCCESS: Table announcements créée avec succès!' as result;
SELECT COUNT(*) as nb_colonnes FROM information_schema.columns WHERE table_name = 'announcements';
-- 4. Taper \q pour quitter psql
-- 5. Taper exit pour quitter le conteneur
+1 -1
View File
@@ -35,7 +35,7 @@ The platform is built with a clear separation of concerns, utilizing a modern fu
- **Invoice Verification Cache:** Robust caching system for invoice verification results with automatic expiration and conflict resolution. Enhanced with unique constraint handling and graceful error management for production stability (August 2025). Fixed production SSL certificate errors and fetch timeout loops with enhanced error handling, network timeout protection, and error result caching to prevent infinite retry loops (August 2025).
- **UI Scrollbar Optimization:** Eliminated redundant vertical scrollbar on the right side of the screen while preserving necessary internal page scrolling. Implemented global CSS rules with `overflow: hidden` on html/body/root and Layout height management to prevent vertical overflow issues in production (August 2025).
- **Task Management:** Système complet de gestion des tâches avec fonctionnalités temporelles avancées - tri intelligent (pending > priorité > date), dates d'échéance avec sélecteur calendrier, indicateurs visuels pour tâches en retard/urgentes, filtres par échéance (aujourd'hui, cette semaine, en retard, sans échéance), vue Kanban et liste, badges colorés pour statut temporel. Interface optimisée pour suivi prioritaire des tâches non validées. Correction critique de l'isolation des données : chaque magasin ne voit maintenant que ses propres tâches (Août 2025). **PRODUCTION FIX (Août 2025)** : Résolution du problème de rechargements multiples nécessaires pour l'administrateur - le cache des tâches s'invalide maintenant automatiquement lors du changement de magasin sélectionné.
- **Information System (Announcements):** Système d'informations complet remplaçant la carte commandes clients dans le dashboard - gestion d'annonces avec niveaux de priorité (normal, important, urgent), contrôle d'accès basé sur les rôles (admin : CRUD complet, autres rôles : lecture seule), tri intelligent par priorité et date, filtrage par magasin pour administrateurs, interface moderne avec badges colorés et indicateurs visuels. Intégration complète avec migrations automatiques et fichier init.sql complet pour nouvelles installations (Août 2025).
- **Information System (Announcements):** Système d'informations complet remplaçant la carte commandes clients dans le dashboard - gestion d'annonces avec niveaux de priorité (normal, important, urgent), contrôle d'accès basé sur les rôles (admin : CRUD complet, autres rôles : lecture seule), tri intelligent par priorité et date, filtrage par magasin pour administrateurs, interface moderne avec badges colorés et indicateurs visuels. Intégration complète avec migrations automatiques et fichier init.sql complet pour nouvelles installations. **MIGRATION AUTOMATIQUE (Août 2025)** : Système de migration automatique intégré au Dockerfile avec scripts de déploiement pour créer automatiquement toutes les tables lors des mises à jour Docker.
- **DLC Module Permissions:** Correction des permissions de validation DLC pour permettre aux admin, directeur et manager de valider les produits DLC. Ajout de logs de debug pour traçabilité des validations (Août 2025).
- **User and Permission Management:** Granular access controls ensuring that users (e.g., employees) have appropriate permissions for tasks like creating customer orders.
- **Reporting:** Statistical reporting, including monthly summaries of deliveries based on `deliveredDate`.
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# Script de migration automatique - Crée UNIQUEMENT la table announcements
# Toutes les autres tables existent déjà en production
set -e
echo "🔄 [AUTO-MIGRATE] Vérification de la table announcements..."
# Vérifier si la base de données est accessible
if ! psql "$DATABASE_URL" -c "SELECT 1;" > /dev/null 2>&1; then
echo "❌ [AUTO-MIGRATE] Impossible de se connecter à la base de données"
exit 1
fi
echo "✅ [AUTO-MIGRATE] Connexion à la base de données réussie"
# Vérifier si la table announcements existe
if psql "$DATABASE_URL" -tAc "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema='public' AND table_name='announcements');" | grep -q "f"; then
echo "🔧 [AUTO-MIGRATE] Création de la table announcements..."
psql "$DATABASE_URL" << 'EOF'
CREATE TABLE announcements (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL,
group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')),
CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
);
CREATE INDEX idx_announcements_priority ON announcements(priority);
CREATE INDEX idx_announcements_created_at ON announcements(created_at DESC);
CREATE INDEX idx_announcements_author_id ON announcements(author_id);
CREATE INDEX idx_announcements_group_id ON announcements(group_id);
EOF
echo "✅ [AUTO-MIGRATE] Table announcements créée avec succès"
else
echo "ℹ️ [AUTO-MIGRATE] Table announcements existe déjà - aucune action nécessaire"
fi
echo "✅ [AUTO-MIGRATE] Migration terminée!"
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# Point d'entrée Docker avec migration automatique
# Ce script remplace le point d'entrée par défaut du conteneur
set -e
echo "🚀 [ENTRYPOINT] Démarrage du conteneur avec migration automatique..."
# Attendre que la base de données soit prête
echo "⏳ [ENTRYPOINT] Attente de la base de données..."
timeout=60
counter=0
while ! psql "$DATABASE_URL" -c "SELECT 1;" > /dev/null 2>&1; do
counter=$((counter + 1))
if [ $counter -gt $timeout ]; then
echo "❌ [ENTRYPOINT] Timeout: impossible de se connecter à la base de données après ${timeout}s"
exit 1
fi
echo "⏳ [ENTRYPOINT] Tentative $counter/$timeout..."
sleep 1
done
echo "✅ [ENTRYPOINT] Base de données accessible"
# Exécuter les migrations automatiques
if [ -f "/app/scripts/auto-migrate-production.sh" ]; then
echo "🔄 [ENTRYPOINT] Exécution des migrations automatiques..."
chmod +x /app/scripts/auto-migrate-production.sh
/app/scripts/auto-migrate-production.sh
else
echo "⚠️ [ENTRYPOINT] Script de migration non trouvé, poursuite sans migration"
fi
# Démarrer l'application
echo "🎯 [ENTRYPOINT] Démarrage de l'application..."
exec "$@"
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
# Script minimal pour créer uniquement la table announcements
# Usage: docker exec logiflow-logiflow-1 /app/scripts/fix-announcements-only.sh
echo "🔧 [FIX] Création de la table announcements uniquement..."
# Créer la table announcements
psql "$DATABASE_URL" << 'EOF'
CREATE TABLE IF NOT EXISTS announcements (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL,
group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
CONSTRAINT announcements_priority_check CHECK (priority IN ('normal', 'important', 'urgent')),
CONSTRAINT announcements_author_id_fkey FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE,
CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority);
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_announcements_author_id ON announcements(author_id);
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
EOF
echo "✅ [FIX] Table announcements créée. Vérification..."
# Vérifier que la table existe
if psql "$DATABASE_URL" -tAc "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='announcements');" | grep -q "t"; then
echo "✅ [FIX] Succès: La table announcements existe maintenant"
# Afficher la structure
echo "📋 [FIX] Structure de la table:"
psql "$DATABASE_URL" -c "SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'announcements' ORDER BY ordinal_position;"
else
echo "❌ [FIX] Erreur: La table announcements n'a pas été créée"
exit 1
fi
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# Script de migration manuelle pour forcer une mise à jour
# Usage: docker exec logiflow-logiflow-1 /app/scripts/manual-migrate.sh
echo "🔧 [MANUAL-MIGRATE] Début de la migration manuelle forcée..."
# Sourcer le script de migration automatique
if [ -f "/app/scripts/auto-migrate-production.sh" ]; then
source /app/scripts/auto-migrate-production.sh
else
echo "❌ [MANUAL-MIGRATE] Script de migration automatique non trouvé"
exit 1
fi
echo "✅ [MANUAL-MIGRATE] Migration manuelle terminée!"