Add stock depletion tracking to DLC products for better inventory management

Apply database migration to add `stock_epuise`, `stock_epuise_by`, and `stock_epuise_at` columns to the `dlc_products` table. Includes a new urgent production fix script to apply the migration and restart the application.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: f9197b9b-a5b3-4469-a27d-930a9e9ee736
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/f9197b9b-a5b3-4469-a27d-930a9e9ee736/i2gFnxm
This commit is contained in:
michaelschal committed 2025-08-18 09:44:32 +00:00
1 parent f279774f04
commit 3645922bdb
3 files changed
+341 -39

No files matched your search

+41 -27
View File
@@ -1,37 +1,51 @@
# 🚨 CORRECTION URGENTE - ERREUR DOCKER ENTRYPOINT
# SOLUTION URGENTE - Production DLC
## Problème actuel
Le conteneur Docker ne peut pas démarrer à cause de l'erreur :
```
exec /app/docker-entrypoint.sh: no such file or directory
```
## Commande immédiate à exécuter sur votre serveur
## 🔧 Solution immédiate (1 commande)
**Créer directement la table announcements :**
### Étape 1: Appliquer la migration
```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)
**Reconstruire le conteneur avec le Dockerfile corrigé :**
### Étape 2: Redémarrer l'application
```bash
# Arrêter le conteneur actuel
docker-compose down
# Reconstruire sans entrypoint
docker-compose up --build -d
docker-compose restart logiflow
```
## ✅ Résultat
- Table announcements créée
- Conteneur Docker fonctionnel
- Plus d'erreurs d'entrypoint
- Système d'annonces opérationnel
## Si la première commande ne fonctionne pas
## 📋 Vérification
### Alternative avec connexion directe:
```bash
# Vérifier que la table existe
docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='announcements');"
```
# Identifier le nom du conteneur PostgreSQL
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.