mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 05:58:23 +02:00
7 files changed
+581
-41
No files matched your search
+2
-2
@@ -114,5 +114,5 @@ RUN chmod +x /app/scripts/auto-migrate-production.sh && \
|
|||||||
ls -la /app/scripts/ && \
|
ls -la /app/scripts/ && \
|
||||||
test -f /app/scripts/docker-entrypoint.sh || echo "ERREUR: docker-entrypoint.sh manquant"
|
test -f /app/scripts/docker-entrypoint.sh || echo "ERREUR: docker-entrypoint.sh manquant"
|
||||||
|
|
||||||
# Start application normally (migration applied separately)
|
# Apply migrations and start application
|
||||||
CMD ["node", "dist/index.js"]
|
CMD ["sh", "-c", "if [ -f /app/scripts/auto-sync-migrations.sh ]; then /app/scripts/auto-sync-migrations.sh; fi && node dist/index.js"]
|
||||||
+41
-27
@@ -1,37 +1,51 @@
|
|||||||
# 🚨 CORRECTION URGENTE - ERREUR DOCKER ENTRYPOINT
|
# SOLUTION URGENTE - Production DLC
|
||||||
|
|
||||||
## Problème actuel
|
## Commande immédiate à exécuter sur votre serveur
|
||||||
Le conteneur Docker ne peut pas démarrer à cause de l'erreur :
|
|
||||||
```
|
|
||||||
exec /app/docker-entrypoint.sh: no such file or directory
|
|
||||||
```
|
|
||||||
|
|
||||||
## 🔧 Solution immédiate (1 commande)
|
### Étape 1: Appliquer la migration
|
||||||
|
|
||||||
**Créer directement la table announcements :**
|
|
||||||
```bash
|
```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);"
|
docker-compose exec logiflow-db psql -U logiflow_admin -d logiflow_db << 'EOF'
|
||||||
|
ALTER TABLE dlc_products
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
|
||||||
|
|
||||||
|
SELECT 'Migration DLC terminée' as status;
|
||||||
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🛠️ Correction du Docker (pour arrêter les erreurs)
|
### Étape 2: Redémarrer l'application
|
||||||
|
|
||||||
**Reconstruire le conteneur avec le Dockerfile corrigé :**
|
|
||||||
```bash
|
```bash
|
||||||
# Arrêter le conteneur actuel
|
docker-compose restart logiflow
|
||||||
docker-compose down
|
|
||||||
|
|
||||||
# Reconstruire sans entrypoint
|
|
||||||
docker-compose up --build -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## ✅ Résultat
|
## Si la première commande ne fonctionne pas
|
||||||
- Table announcements créée
|
|
||||||
- Conteneur Docker fonctionnel
|
|
||||||
- Plus d'erreurs d'entrypoint
|
|
||||||
- Système d'annonces opérationnel
|
|
||||||
|
|
||||||
## 📋 Vérification
|
### Alternative avec connexion directe:
|
||||||
```bash
|
```bash
|
||||||
# Vérifier que la table existe
|
# Identifier le nom du conteneur PostgreSQL
|
||||||
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='announcements');"
|
docker ps | grep postgres
|
||||||
```
|
|
||||||
|
# Se connecter directement
|
||||||
|
docker exec -it [NOM_CONTENEUR_POSTGRES] psql -U logiflow_admin -d logiflow_db
|
||||||
|
|
||||||
|
# Puis dans psql, exécuter:
|
||||||
|
ALTER TABLE dlc_products
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
|
||||||
|
|
||||||
|
\q
|
||||||
|
```
|
||||||
|
|
||||||
|
## Vérification
|
||||||
|
Après l'application, vérifiez que les colonnes existent :
|
||||||
|
```bash
|
||||||
|
docker-compose exec logiflow-db psql -U logiflow_admin -d logiflow_db -c "\d dlc_products"
|
||||||
|
```
|
||||||
|
|
||||||
|
L'erreur "column does not exist" disparaîtra immédiatement.
|
||||||
+234
@@ -0,0 +1,234 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' }
|
||||||
|
|
||||||
|
Customer Orders returned: 10 items
|
||||||
|
|
||||||
|
GET /api/customer-orders 304 in 63ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getOrders() récupéré 33 commandes avec relations
|
||||||
|
|
||||||
|
Orders returned: 33 items
|
||||||
|
|
||||||
|
GET /api/orders 304 in 128ms
|
||||||
|
|
||||||
|
🔗 PRODUCTION: getDeliveries() récupéré 49 livraisons avec relations
|
||||||
|
|
||||||
|
Deliveries returned: 49 items
|
||||||
|
|
||||||
|
GET /api/deliveries 304 in 154ms
|
||||||
|
|
||||||
|
GET /api/groups 304 in 57ms
|
||||||
|
|
||||||
|
GET /api/user 304 in 7ms
|
||||||
|
|
||||||
|
GET /api/suppliers 304 in 9ms
|
||||||
|
|
||||||
|
Error fetching DLC products: error: column dlc_products.stock_epuise 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.getDlcProducts (file:///app/dist/index.js:2187:25)
|
||||||
|
|
||||||
|
at async file:///app/dist/index.js:6178:28 {
|
||||||
|
|
||||||
|
length: 124,
|
||||||
|
|
||||||
|
severity: 'ERROR',
|
||||||
|
|
||||||
|
code: '42703',
|
||||||
|
|
||||||
|
detail: undefined,
|
||||||
|
|
||||||
|
hint: undefined,
|
||||||
|
|
||||||
|
position: '337',
|
||||||
|
|
||||||
|
internalPosition: undefined,
|
||||||
|
|
||||||
|
internalQuery: undefined,
|
||||||
|
|
||||||
|
where: undefined,
|
||||||
|
|
||||||
|
schema: undefined,
|
||||||
|
|
||||||
|
table: undefined,
|
||||||
|
|
||||||
|
column: undefined,
|
||||||
|
|
||||||
|
dataType: undefined,
|
||||||
|
|
||||||
|
constraint: undefined,
|
||||||
|
|
||||||
|
file: 'parse_relation.c',
|
||||||
|
|
||||||
|
line: '3665',
|
||||||
|
|
||||||
|
routine: 'errorMissingColumn'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/dlc-products 500 in 19ms
|
||||||
|
|
||||||
|
Error fetching DLC products: error: column dlc_products.stock_epuise 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.getDlcProducts (file:///app/dist/index.js:2187:25)
|
||||||
|
|
||||||
|
at async file:///app/dist/index.js:6178:28 {
|
||||||
|
|
||||||
|
length: 124,
|
||||||
|
|
||||||
|
severity: 'ERROR',
|
||||||
|
|
||||||
|
code: '42703',
|
||||||
|
|
||||||
|
detail: undefined,
|
||||||
|
|
||||||
|
hint: undefined,
|
||||||
|
|
||||||
|
position: '337',
|
||||||
|
|
||||||
|
internalPosition: undefined,
|
||||||
|
|
||||||
|
internalQuery: undefined,
|
||||||
|
|
||||||
|
where: undefined,
|
||||||
|
|
||||||
|
schema: undefined,
|
||||||
|
|
||||||
|
table: undefined,
|
||||||
|
|
||||||
|
column: undefined,
|
||||||
|
|
||||||
|
dataType: undefined,
|
||||||
|
|
||||||
|
constraint: undefined,
|
||||||
|
|
||||||
|
file: 'parse_relation.c',
|
||||||
|
|
||||||
|
line: '3665',
|
||||||
|
|
||||||
|
routine: 'errorMissingColumn'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/dlc-products 500 in 27ms
|
||||||
|
|
||||||
|
Error fetching DLC products: error: column dlc_products.stock_epuise 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.getDlcProducts (file:///app/dist/index.js:2187:25)
|
||||||
|
|
||||||
|
at async file:///app/dist/index.js:6178:28 {
|
||||||
|
|
||||||
|
length: 124,
|
||||||
|
|
||||||
|
severity: 'ERROR',
|
||||||
|
|
||||||
|
code: '42703',
|
||||||
|
|
||||||
|
detail: undefined,
|
||||||
|
|
||||||
|
hint: undefined,
|
||||||
|
|
||||||
|
position: '337',
|
||||||
|
|
||||||
|
internalPosition: undefined,
|
||||||
|
|
||||||
|
internalQuery: undefined,
|
||||||
|
|
||||||
|
where: undefined,
|
||||||
|
|
||||||
|
schema: undefined,
|
||||||
|
|
||||||
|
table: undefined,
|
||||||
|
|
||||||
|
column: undefined,
|
||||||
|
|
||||||
|
dataType: undefined,
|
||||||
|
|
||||||
|
constraint: undefined,
|
||||||
|
|
||||||
|
file: 'parse_relation.c',
|
||||||
|
|
||||||
|
line: '3665',
|
||||||
|
|
||||||
|
routine: 'errorMissingColumn'
|
||||||
@@ -8,6 +8,13 @@
|
|||||||
"when": 1752862907657,
|
"when": 1752862907657,
|
||||||
"tag": "0000_flashy_blur",
|
"tag": "0000_flashy_blur",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 1,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1755510400000,
|
||||||
|
"tag": "002_add_dlc_stock_epuise",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Executable
+94
@@ -0,0 +1,94 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script de synchronisation automatique des migrations
|
||||||
|
# Applique toutes les migrations SQL manquantes et synchronise le schéma
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🔄 [SYNC] Synchronisation automatique des migrations"
|
||||||
|
echo "=================================================="
|
||||||
|
|
||||||
|
# Fonction de logging
|
||||||
|
log() {
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vérification de la connexion base de données
|
||||||
|
if [ -z "$DATABASE_URL" ]; then
|
||||||
|
log "❌ DATABASE_URL non défini"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "🔍 Connexion à la base de données..."
|
||||||
|
|
||||||
|
# Test de connexion
|
||||||
|
if ! psql "$DATABASE_URL" -c "SELECT 1;" > /dev/null 2>&1; then
|
||||||
|
log "❌ Impossible de se connecter à la base de données"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "✅ Connexion base de données réussie"
|
||||||
|
|
||||||
|
# Vérifier si la table dlc_products existe
|
||||||
|
log "🔍 Vérification de la table dlc_products..."
|
||||||
|
|
||||||
|
if ! psql "$DATABASE_URL" -tAc "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='dlc_products');" | grep -q "t"; then
|
||||||
|
log "❌ Table dlc_products non trouvée - exécution de la migration initiale nécessaire"
|
||||||
|
|
||||||
|
# Appliquer la migration initiale depuis 0000_flashy_blur.sql
|
||||||
|
if [ -f "migrations/0000_flashy_blur.sql" ]; then
|
||||||
|
log "🔄 Application de la migration initiale..."
|
||||||
|
psql "$DATABASE_URL" -f "migrations/0000_flashy_blur.sql"
|
||||||
|
log "✅ Migration initiale appliquée"
|
||||||
|
else
|
||||||
|
log "❌ Fichier de migration initiale non trouvé"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Vérifier si les colonnes stock_epuise existent
|
||||||
|
log "🔍 Vérification des colonnes DLC stock épuisé..."
|
||||||
|
|
||||||
|
COLUMNS_EXIST=$(psql "$DATABASE_URL" -tAc "
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name='dlc_products'
|
||||||
|
AND column_name IN ('stock_epuise', 'stock_epuise_by', 'stock_epuise_at');
|
||||||
|
")
|
||||||
|
|
||||||
|
if [ "$COLUMNS_EXIST" != "3" ]; then
|
||||||
|
log "🔄 Application de la migration DLC stock épuisé ($COLUMNS_EXIST/3 colonnes trouvées)..."
|
||||||
|
|
||||||
|
# Appliquer la migration DLC
|
||||||
|
psql "$DATABASE_URL" -f "migrations/002_add_dlc_stock_epuise.sql"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log "✅ Migration DLC stock épuisé appliquée"
|
||||||
|
else
|
||||||
|
log "❌ Erreur lors de la migration DLC"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log "✅ Colonnes DLC stock épuisé déjà présentes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Vérification finale
|
||||||
|
log "🔍 Vérification finale des colonnes..."
|
||||||
|
|
||||||
|
FINAL_CHECK=$(psql "$DATABASE_URL" -tAc "
|
||||||
|
SELECT column_name
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name='dlc_products'
|
||||||
|
AND column_name IN ('stock_epuise', 'stock_epuise_by', 'stock_epuise_at')
|
||||||
|
ORDER BY column_name;
|
||||||
|
")
|
||||||
|
|
||||||
|
if [ $(echo "$FINAL_CHECK" | wc -l) -eq 3 ]; then
|
||||||
|
log "✅ Toutes les colonnes DLC sont présentes:"
|
||||||
|
echo "$FINAL_CHECK" | sed 's/^/ - /'
|
||||||
|
else
|
||||||
|
log "❌ Colonnes manquantes détectées"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "🎉 Synchronisation des migrations terminée avec succès"
|
||||||
Executable
+137
@@ -0,0 +1,137 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script de correction des migrations pour la production
|
||||||
|
# Solution complète pour appliquer automatiquement les migrations DLC
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🚨 [PRODUCTION FIX] Correction automatique des migrations"
|
||||||
|
echo "========================================================"
|
||||||
|
|
||||||
|
# Fonction de logging avec timestamp
|
||||||
|
log() {
|
||||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vérification de Docker Compose
|
||||||
|
if ! command -v docker-compose &> /dev/null; then
|
||||||
|
log "❌ docker-compose non trouvé"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Vérification que le conteneur PostgreSQL est actif
|
||||||
|
log "🔍 Vérification du conteneur PostgreSQL..."
|
||||||
|
|
||||||
|
if ! docker-compose ps | grep -q logiflow-db; then
|
||||||
|
log "❌ Conteneur logiflow-db non actif"
|
||||||
|
log "📋 Conteneurs disponibles:"
|
||||||
|
docker-compose ps
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "✅ Conteneur PostgreSQL actif"
|
||||||
|
|
||||||
|
# Application de toutes les migrations manquantes
|
||||||
|
log "🔄 Application des migrations manquantes..."
|
||||||
|
|
||||||
|
# Migration 1: Vérification et création de la structure de base
|
||||||
|
log "📂 Étape 1: Vérification de la structure de base..."
|
||||||
|
|
||||||
|
docker-compose exec -T logiflow-db psql -U logiflow_admin -d logiflow_db << 'EOF'
|
||||||
|
-- Vérifier que la table dlc_products existe
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'dlc_products') THEN
|
||||||
|
RAISE NOTICE 'Table dlc_products manquante - création nécessaire';
|
||||||
|
-- La table sera créée par la migration initiale si nécessaire
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE 'Table dlc_products trouvée';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Migration 2: Application de la migration DLC stock épuisé
|
||||||
|
log "📂 Étape 2: Application de la migration DLC stock épuisé..."
|
||||||
|
|
||||||
|
docker-compose exec -T logiflow-db psql -U logiflow_admin -d logiflow_db << 'EOF'
|
||||||
|
-- Migration DLC Stock Épuisé - Version de production sécurisée
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
column_count integer;
|
||||||
|
BEGIN
|
||||||
|
-- Compter les colonnes existantes
|
||||||
|
SELECT COUNT(*) INTO column_count
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'dlc_products'
|
||||||
|
AND column_name IN ('stock_epuise', 'stock_epuise_by', 'stock_epuise_at');
|
||||||
|
|
||||||
|
RAISE NOTICE 'Colonnes DLC stock épuisé trouvées: %', column_count;
|
||||||
|
|
||||||
|
-- Ajouter les colonnes manquantes
|
||||||
|
IF column_count < 3 THEN
|
||||||
|
RAISE NOTICE 'Application de la migration DLC...';
|
||||||
|
|
||||||
|
-- Ajouter les colonnes avec protection IF NOT EXISTS
|
||||||
|
ALTER TABLE dlc_products
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
|
||||||
|
|
||||||
|
-- Créer l'index
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
|
||||||
|
|
||||||
|
-- Initialiser les valeurs existantes
|
||||||
|
UPDATE dlc_products
|
||||||
|
SET stock_epuise = false
|
||||||
|
WHERE stock_epuise IS NULL;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Migration DLC appliquée avec succès';
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE 'Migration DLC déjà appliquée';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
-- Vérification finale
|
||||||
|
SELECT
|
||||||
|
'Migration DLC - Verification finale' as status,
|
||||||
|
COUNT(*) as colonnes_dlc_trouvees
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'dlc_products'
|
||||||
|
AND column_name IN ('stock_epuise', 'stock_epuise_by', 'stock_epuise_at');
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log "✅ Migration DLC appliquée avec succès"
|
||||||
|
else
|
||||||
|
log "❌ Erreur lors de la migration DLC"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Redémarrage de l'application
|
||||||
|
log "🔄 Redémarrage de l'application..."
|
||||||
|
docker-compose restart logiflow
|
||||||
|
|
||||||
|
# Attendre que l'application redémarre
|
||||||
|
log "⏳ Attente du redémarrage (30 secondes)..."
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
# Vérification finale
|
||||||
|
log "🔍 Vérification finale de l'API DLC..."
|
||||||
|
|
||||||
|
# Test de l'API DLC
|
||||||
|
HEALTH_CHECK=$(docker-compose logs logiflow 2>&1 | tail -20 | grep -c "Error fetching DLC products" || echo "0")
|
||||||
|
|
||||||
|
if [ "$HEALTH_CHECK" -eq 0 ]; then
|
||||||
|
log "✅ API DLC fonctionne correctement"
|
||||||
|
else
|
||||||
|
log "⚠️ Des erreurs DLC persistent - vérification manuelle nécessaire"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🎉 CORRECTION DE PRODUCTION TERMINÉE"
|
||||||
|
echo "=================================="
|
||||||
|
echo "✅ Migrations DLC appliquées"
|
||||||
|
echo "✅ Application redémarrée"
|
||||||
|
echo "✅ L'erreur 'column does not exist' devrait être résolue"
|
||||||
|
echo ""
|
||||||
|
echo "Vérifiez maintenant votre interface DLC pour confirmer que tout fonctionne."
|
||||||
+66
-12
@@ -1,19 +1,73 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Script d'urgence pour corriger la production immédiatement
|
|
||||||
|
|
||||||
echo "🚨 CORRECTION URGENTE - Création de la table announcements"
|
# Script de correction urgente pour la production
|
||||||
|
# Applique la migration DLC immédiatement
|
||||||
|
|
||||||
# Option 1: Copier le fichier SQL dans le conteneur et l'exécuter
|
set -e
|
||||||
echo "📋 Copie du script SQL dans le conteneur..."
|
|
||||||
docker cp create_announcements_production.sql logiflow-logiflow-1:/tmp/
|
|
||||||
|
|
||||||
echo "🔧 Exécution du script SQL..."
|
echo "🚨 CORRECTION URGENTE - Migration DLC Production"
|
||||||
docker exec logiflow-logiflow-1 psql $DATABASE_URL -f /tmp/create_announcements_production.sql
|
echo "================================================"
|
||||||
|
|
||||||
echo "✅ Script exécuté. Vérification..."
|
# Vérifier que Docker Compose est disponible
|
||||||
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='announcements') as table_exists;"
|
if ! command -v docker-compose &> /dev/null; then
|
||||||
|
echo "❌ docker-compose non trouvé"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "🎯 Redémarrage de l'application..."
|
# Vérifier que le conteneur PostgreSQL est en cours d'exécution
|
||||||
docker restart logiflow-logiflow-1
|
if ! docker-compose ps | grep -q logiflow-db; then
|
||||||
|
echo "❌ Conteneur logiflow-db non trouvé"
|
||||||
|
echo "Containers disponibles:"
|
||||||
|
docker-compose ps
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "✅ CORRECTION TERMINÉE"
|
echo "✅ Conteneur PostgreSQL trouvé"
|
||||||
|
|
||||||
|
# Appliquer la migration DLC
|
||||||
|
echo "🔄 Application de la migration DLC..."
|
||||||
|
|
||||||
|
docker-compose exec -T logiflow-db psql -U logiflow_admin -d logiflow_db << 'EOF'
|
||||||
|
-- Migration DLC Stock Épuisé
|
||||||
|
ALTER TABLE dlc_products
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise boolean DEFAULT false NOT NULL,
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_by varchar(255),
|
||||||
|
ADD COLUMN IF NOT EXISTS stock_epuise_at timestamp;
|
||||||
|
|
||||||
|
-- Index pour performance
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_dlc_products_stock_epuise ON dlc_products(stock_epuise);
|
||||||
|
|
||||||
|
-- Vérification
|
||||||
|
SELECT 'Migration DLC appliquée avec succès' as status;
|
||||||
|
|
||||||
|
-- Afficher les colonnes ajoutées
|
||||||
|
SELECT column_name, data_type
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'dlc_products'
|
||||||
|
AND column_name LIKE '%stock_epuise%'
|
||||||
|
ORDER BY column_name;
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ Migration DLC appliquée avec succès"
|
||||||
|
else
|
||||||
|
echo "❌ Erreur lors de la migration"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Redémarrer l'application
|
||||||
|
echo "🔄 Redémarrage de l'application..."
|
||||||
|
docker-compose restart logiflow
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ Application redémarrée"
|
||||||
|
else
|
||||||
|
echo "❌ Erreur lors du redémarrage"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🎉 CORRECTION TERMINÉE"
|
||||||
|
echo "L'erreur 'column does not exist' devrait maintenant être résolue"
|
||||||
|
echo ""
|
||||||
|
echo "Vérifiez dans les logs que l'API /api/dlc-products fonctionne maintenant"
|
||||||
Reference in new issue
Block a user