mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
6 files changed
+269
-2
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 223 KiB |
@@ -0,0 +1,77 @@
|
||||
-- 🔍 DIAGNOSTIC PRODUCTION COMPLET - Module Avoirs
|
||||
-- Copiez-collez ce script dans votre utilitaire SQL pour diagnostic précis
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- SECTION 1: STRUCTURE DES TABLES
|
||||
SELECT 'VÉRIFICATION STRUCTURE TABLES' AS section_title;
|
||||
|
||||
-- Table avoirs - structure exacte
|
||||
SELECT 'STRUCTURE_AVOIRS' AS check_type, column_name, data_type, is_nullable, column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'avoirs' AND table_schema = 'public'
|
||||
ORDER BY ordinal_position;
|
||||
|
||||
-- Table suppliers - structure exacte
|
||||
SELECT 'STRUCTURE_SUPPLIERS' AS check_type, column_name, data_type, is_nullable
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'suppliers' AND table_schema = 'public'
|
||||
ORDER BY ordinal_position;
|
||||
|
||||
-- Table groups - structure exacte
|
||||
SELECT 'STRUCTURE_GROUPS' AS check_type, column_name, data_type, is_nullable
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'groups' AND table_schema = 'public'
|
||||
ORDER BY ordinal_position;
|
||||
|
||||
-- Table users - structure exacte
|
||||
SELECT 'STRUCTURE_USERS' AS check_type, column_name, data_type, is_nullable
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'users' AND table_schema = 'public'
|
||||
ORDER BY ordinal_position;
|
||||
|
||||
-- SECTION 2: CONTRAINTES
|
||||
SELECT 'CONTRAINTES_AVOIRS' AS check_type, conname AS constraint_name, contype AS type,
|
||||
confrelid::regclass AS referenced_table
|
||||
FROM pg_constraint
|
||||
WHERE conrelid = 'avoirs'::regclass;
|
||||
|
||||
-- SECTION 3: DONNÉES EXISTANTES
|
||||
SELECT 'COMPTES_TABLES' AS check_type, 'suppliers' AS table_name, COUNT(*) AS count FROM suppliers
|
||||
UNION ALL
|
||||
SELECT 'COMPTES_TABLES', 'groups', COUNT(*) FROM groups
|
||||
UNION ALL
|
||||
SELECT 'COMPTES_TABLES', 'users', COUNT(*) FROM users
|
||||
UNION ALL
|
||||
SELECT 'COMPTES_TABLES', 'avoirs', COUNT(*) FROM avoirs;
|
||||
|
||||
-- SECTION 4: EXEMPLES DE DONNÉES (si elles existent)
|
||||
-- Suppliers
|
||||
SELECT 'EXEMPLES_SUPPLIERS' AS check_type, id, name FROM suppliers LIMIT 3;
|
||||
|
||||
-- Groups
|
||||
SELECT 'EXEMPLES_GROUPS' AS check_type, id, name FROM groups LIMIT 3;
|
||||
|
||||
-- Users
|
||||
SELECT 'EXEMPLES_USERS' AS check_type, id,
|
||||
COALESCE(username, 'no_username') AS username,
|
||||
role
|
||||
FROM users LIMIT 3;
|
||||
|
||||
-- SECTION 5: TEST DE COMPATIBILITÉ
|
||||
-- Test si on peut insérer avec des champs NULL
|
||||
SELECT 'TEST_COMPATIBILITÉ' AS check_type,
|
||||
CASE
|
||||
WHEN (SELECT is_nullable FROM information_schema.columns
|
||||
WHERE table_name = 'avoirs' AND column_name = 'invoice_reference') = 'YES'
|
||||
THEN 'invoice_reference_NULLABLE'
|
||||
ELSE 'invoice_reference_NOT_NULL'
|
||||
END AS invoice_ref_status,
|
||||
CASE
|
||||
WHEN (SELECT is_nullable FROM information_schema.columns
|
||||
WHERE table_name = 'avoirs' AND column_name = 'amount') = 'YES'
|
||||
THEN 'amount_NULLABLE'
|
||||
ELSE 'amount_NOT_NULL'
|
||||
END AS amount_status;
|
||||
|
||||
ROLLBACK; -- Ne pas sauvegarder, c'est juste du diagnostic
|
||||
@@ -0,0 +1,85 @@
|
||||
# 🔧 GUIDE DE DÉPLOIEMENT URGENT - Serveur de Production
|
||||
|
||||
## 🚨 PROBLÈME IDENTIFIÉ
|
||||
Votre serveur de production utilise encore l'ancien code avec les erreurs TypeScript, pas le code corrigé.
|
||||
|
||||
## 📋 ÉTAPES DE RÉSOLUTION
|
||||
|
||||
### 1. VÉRIFIEZ LES LOGS DU SERVEUR
|
||||
```bash
|
||||
# Option 1: Si vous utilisez PM2
|
||||
pm2 logs your_app_name
|
||||
|
||||
# Option 2: Si vous utilisez systemctl
|
||||
journalctl -u your_service_name -f
|
||||
|
||||
# Option 3: Si vous utilisez Docker
|
||||
docker logs your_container_name
|
||||
```
|
||||
|
||||
### 2. IDENTIFIEZ L'ERREUR EXACTE
|
||||
Cherchez dans les logs des erreurs comme :
|
||||
- `No overload matches this call`
|
||||
- `AuthRequest`
|
||||
- `requireModulePermission`
|
||||
|
||||
### 3. DÉPLOYEZ LE CODE CORRIGÉ
|
||||
|
||||
**Option A - Git (Recommandé)**
|
||||
```bash
|
||||
cd /chemin/vers/votre/application
|
||||
git pull origin main
|
||||
# ou
|
||||
git pull origin master
|
||||
```
|
||||
|
||||
**Option B - Copie manuelle**
|
||||
1. Copiez le fichier `server/routes.ts` depuis ce projet Replit
|
||||
2. Remplacez-le sur votre serveur de production
|
||||
|
||||
### 4. VÉRIFIEZ LE CODE DÉPLOYÉ
|
||||
Dans votre fichier `server/routes.ts` en production, vous devez avoir :
|
||||
|
||||
```javascript
|
||||
// ✅ CORRECT - Nouveau code
|
||||
app.get('/api/avoirs', isAuthenticated, async (req: any, res) => {
|
||||
|
||||
// ❌ INCORRECT - Ancien code (cause l'erreur)
|
||||
app.get('/api/avoirs', requireModulePermission('avoir', 'view'), async (req: AuthRequest, res) => {
|
||||
```
|
||||
|
||||
### 5. REDÉMARREZ LE SERVEUR
|
||||
```bash
|
||||
# Option 1: PM2
|
||||
pm2 restart your_app_name
|
||||
|
||||
# Option 2: systemctl
|
||||
systemctl restart your_service_name
|
||||
|
||||
# Option 3: Docker
|
||||
docker restart your_container_name
|
||||
|
||||
# Option 4: Service classique
|
||||
sudo service your_service restart
|
||||
```
|
||||
|
||||
### 6. VÉRIFIEZ QUE ÇA MARCHE
|
||||
1. Rechargez votre page web
|
||||
2. L'erreur générale devrait disparaître
|
||||
3. Testez l'accès aux autres modules
|
||||
4. Testez la création d'un avoir
|
||||
|
||||
## 🎯 DIAGNOSTIC RAPIDE
|
||||
|
||||
Si vous n'arrivez pas à identifier le problème :
|
||||
|
||||
1. **Envoyez-moi les logs d'erreur exacts**
|
||||
2. **Confirmez que le code a été déployé**
|
||||
3. **Vérifiez que le serveur a redémarré**
|
||||
|
||||
## 🚀 APRÈS RÉSOLUTION
|
||||
|
||||
Une fois que l'application fonctionne de nouveau :
|
||||
1. Testez la création d'un avoir
|
||||
2. Si ça ne marche pas, le problème sera alors dans la base de données
|
||||
3. Mais d'abord, résolvez le problème de déploiement !
|
||||
+2
-2
@@ -267,8 +267,8 @@ export const avoirs = pgTable("avoirs", {
|
||||
id: serial("id").primaryKey(),
|
||||
supplierId: integer("supplier_id").notNull(), // Fournisseur
|
||||
groupId: integer("group_id").notNull(), // Magasin/groupe associé - OBLIGATOIRE pour filtrage
|
||||
invoiceReference: varchar("invoice_reference", { length: 255 }).notNull(), // Référence facture
|
||||
amount: decimal("amount", { precision: 10, scale: 2 }).notNull(), // Montant
|
||||
invoiceReference: varchar("invoice_reference", { length: 255 }), // Référence facture (OPTIONNEL)
|
||||
amount: decimal("amount", { precision: 10, scale: 2 }), // Montant (OPTIONNEL)
|
||||
comment: text("comment"), // Commentaire (optionnel)
|
||||
commercialProcessed: boolean("commercial_processed").default(false), // Avoir fait par commercial
|
||||
status: varchar("status", { length: 50 }).notNull().default("En attente de demande"), // En attente de demande, Demandé, Reçu
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
-- 🔍 DIAGNOSTIC COMPLET FINAL - Production
|
||||
-- Trouvons exactement où ça bloque !
|
||||
|
||||
-- SECTION 1: Vérification des tables et leurs structures
|
||||
SELECT 'TABLES EXISTANTES' as check_type;
|
||||
SELECT table_name,
|
||||
(SELECT COUNT(*) FROM information_schema.columns WHERE table_name = t.table_name) as column_count
|
||||
FROM information_schema.tables t
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name IN ('suppliers', 'groups', 'users', 'avoirs')
|
||||
ORDER BY table_name;
|
||||
|
||||
-- SECTION 2: Structure détaillée de la table avoirs
|
||||
SELECT 'STRUCTURE TABLE AVOIRS' as check_type;
|
||||
SELECT column_name, data_type, is_nullable, column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'avoirs'
|
||||
ORDER BY ordinal_position;
|
||||
|
||||
-- SECTION 3: Contraintes de la table avoirs
|
||||
SELECT 'CONTRAINTES AVOIRS' as check_type;
|
||||
SELECT conname as constraint_name,
|
||||
confrelid::regclass as referenced_table,
|
||||
contype as constraint_type
|
||||
FROM pg_constraint
|
||||
WHERE conrelid = 'avoirs'::regclass;
|
||||
|
||||
-- SECTION 4: Données dans les tables liées
|
||||
SELECT 'DONNÉES TABLES LIÉES' as check_type;
|
||||
SELECT 'suppliers' as table_name, COUNT(*) as count FROM suppliers
|
||||
UNION ALL
|
||||
SELECT 'groups', COUNT(*) FROM groups
|
||||
UNION ALL
|
||||
SELECT 'users', COUNT(*) FROM users
|
||||
UNION ALL
|
||||
SELECT 'avoirs', COUNT(*) FROM avoirs;
|
||||
|
||||
-- SECTION 5: Si les tables ont des données, montrez quelques exemples
|
||||
SELECT 'EXEMPLES SUPPLIERS' as check_type;
|
||||
SELECT id, name,
|
||||
CASE WHEN LENGTH(name) > 20 THEN LEFT(name, 20) || '...' ELSE name END as display_name
|
||||
FROM suppliers LIMIT 3;
|
||||
|
||||
SELECT 'EXEMPLES GROUPS' as check_type;
|
||||
SELECT id, name,
|
||||
CASE WHEN LENGTH(name) > 20 THEN LEFT(name, 20) || '...' ELSE name END as display_name
|
||||
FROM groups LIMIT 3;
|
||||
|
||||
SELECT 'EXEMPLES USERS' as check_type;
|
||||
SELECT id,
|
||||
COALESCE(username, 'no_username') as username,
|
||||
CASE WHEN LENGTH(COALESCE(username, 'no_username')) > 15
|
||||
THEN LEFT(COALESCE(username, 'no_username'), 15) || '...'
|
||||
ELSE COALESCE(username, 'no_username') END as display_username
|
||||
FROM users LIMIT 3;
|
||||
|
||||
-- SECTION 6: Test d'insertion simple
|
||||
SELECT 'TEST INSERTION' as check_type;
|
||||
-- Seulement si toutes les tables ont des données
|
||||
SELECT CASE
|
||||
WHEN (SELECT COUNT(*) FROM suppliers) > 0
|
||||
AND (SELECT COUNT(*) FROM groups) > 0
|
||||
AND (SELECT COUNT(*) FROM users) > 0
|
||||
THEN 'READY_FOR_INSERT'
|
||||
ELSE 'MISSING_REFERENCE_DATA'
|
||||
END as insert_status;
|
||||
@@ -0,0 +1,39 @@
|
||||
-- 🔧 CORRECTION CONTRAINTE FOREIGN KEY
|
||||
-- Le problème : l'utilisateur référencé n'existe pas !
|
||||
|
||||
-- ÉTAPE 1: Voir les utilisateurs existants
|
||||
SELECT 'UTILISATEURS EXISTANTS' as check_type;
|
||||
SELECT id, username, role FROM users ORDER BY id;
|
||||
|
||||
-- ÉTAPE 2: Si aucun utilisateur, créer un utilisateur admin
|
||||
INSERT INTO users (id, username, email, role)
|
||||
VALUES ('admin', 'admin', 'admin@test.com', 'admin')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- ÉTAPE 3: Insérer supplier et group de test si nécessaire
|
||||
INSERT INTO suppliers (name) VALUES ('Test Supplier') ON CONFLICT DO NOTHING RETURNING id;
|
||||
INSERT INTO groups (name) VALUES ('Test Group') ON CONFLICT DO NOTHING RETURNING id;
|
||||
|
||||
-- ÉTAPE 4: Test avoir avec utilisateur existant
|
||||
INSERT INTO avoirs (
|
||||
supplier_id,
|
||||
group_id,
|
||||
created_by,
|
||||
invoice_reference,
|
||||
amount,
|
||||
comment
|
||||
) VALUES (
|
||||
(SELECT id FROM suppliers WHERE name = 'Test Supplier' LIMIT 1),
|
||||
(SELECT id FROM groups WHERE name = 'Test Group' LIMIT 1),
|
||||
(SELECT id FROM users WHERE role = 'admin' LIMIT 1), -- Utilise un ID qui existe !
|
||||
'TEST-FK-FIXED',
|
||||
99.99,
|
||||
'Test après correction foreign key'
|
||||
) RETURNING id, created_by;
|
||||
|
||||
-- ÉTAPE 5: Vérification
|
||||
SELECT 'RÉSULTAT INSERTION' as check_type;
|
||||
SELECT COUNT(*) as total_avoirs FROM avoirs;
|
||||
|
||||
-- ÉTAPE 6: Nettoyage du test
|
||||
DELETE FROM avoirs WHERE invoice_reference = 'TEST-FK-FIXED';
|
||||
Reference in new issue
Block a user