mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add diagnostic scripts for checking and fixing data references
Introduce SQL scripts to verify and populate necessary data in suppliers, groups, and users tables for testing avoirs functionality. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/2Jd7tYp
This commit is contained in:
1 parent
d55fa1ed80
commit
29798a0a81
3 files changed
+85
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 221 KiB |
@@ -0,0 +1,46 @@
|
|||||||
|
-- 🔍 DIAGNOSTIC DES RÉFÉRENCES - Trouvons le vrai problème
|
||||||
|
-- Exécutez chaque section séparément
|
||||||
|
|
||||||
|
-- SECTION 1: Vérifier les tables dépendantes
|
||||||
|
SELECT 'suppliers' as table_name, COUNT(*) as record_count FROM suppliers
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'groups' as table_name, COUNT(*) FROM groups
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'users' as table_name, COUNT(*) FROM users;
|
||||||
|
|
||||||
|
-- SECTION 2: Voir les premiers IDs disponibles
|
||||||
|
SELECT 'supplier_ids' as type, string_agg(id::text, ', ') as available_ids
|
||||||
|
FROM (SELECT id FROM suppliers LIMIT 5) s
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'group_ids' as type, string_agg(id::text, ', ')
|
||||||
|
FROM (SELECT id FROM groups LIMIT 5) g
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'user_ids' as type, string_agg(id::text, ', ')
|
||||||
|
FROM (SELECT id FROM users LIMIT 5) u;
|
||||||
|
|
||||||
|
-- SECTION 3: Vérifier les types de colonnes
|
||||||
|
SELECT table_name, column_name, data_type
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name IN ('suppliers', 'groups', 'users', 'avoirs')
|
||||||
|
AND column_name IN ('id', 'created_by')
|
||||||
|
ORDER BY table_name, column_name;
|
||||||
|
|
||||||
|
-- SECTION 4: Test d'insertion avec de vraies données
|
||||||
|
-- ATTENTION: Remplacez les valeurs par les vrais IDs trouvés ci-dessus
|
||||||
|
INSERT INTO avoirs (
|
||||||
|
supplier_id,
|
||||||
|
group_id,
|
||||||
|
invoice_reference,
|
||||||
|
amount,
|
||||||
|
comment,
|
||||||
|
commercial_processed,
|
||||||
|
created_by
|
||||||
|
) VALUES (
|
||||||
|
(SELECT id FROM suppliers LIMIT 1), -- Premier supplier existant
|
||||||
|
(SELECT id FROM groups LIMIT 1), -- Premier group existant
|
||||||
|
'TEST-REF-' || EXTRACT(EPOCH FROM NOW()),
|
||||||
|
29.99,
|
||||||
|
'Test avec vraies données',
|
||||||
|
false,
|
||||||
|
(SELECT id FROM users LIMIT 1)::varchar -- Premier user existant
|
||||||
|
) RETURNING id, created_at;
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
-- 🔧 CORRECTION DES RÉFÉRENCES - Si les tables sont vides
|
||||||
|
-- Utilisez ce script SI les tables suppliers/groups/users sont vides
|
||||||
|
|
||||||
|
-- 1. Créer des données de test minimales pour suppliers
|
||||||
|
INSERT INTO suppliers (name, contact_email) VALUES
|
||||||
|
('Fournisseur Test', 'test@supplier.com')
|
||||||
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
-- 2. Créer des données de test minimales pour groups
|
||||||
|
INSERT INTO groups (name, description) VALUES
|
||||||
|
('Magasin Test', 'Magasin de test pour avoirs')
|
||||||
|
ON CONFLICT DO NOTHING;
|
||||||
|
|
||||||
|
-- 3. Vérifier/créer un utilisateur admin
|
||||||
|
INSERT INTO users (id, username, email, role) VALUES
|
||||||
|
('admin', 'admin', 'admin@test.com', 'admin')
|
||||||
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
|
-- 4. Maintenant tester l'insertion avoir
|
||||||
|
INSERT INTO avoirs (
|
||||||
|
supplier_id,
|
||||||
|
group_id,
|
||||||
|
invoice_reference,
|
||||||
|
amount,
|
||||||
|
comment,
|
||||||
|
commercial_processed,
|
||||||
|
created_by
|
||||||
|
) VALUES (
|
||||||
|
(SELECT id FROM suppliers WHERE name = 'Fournisseur Test'),
|
||||||
|
(SELECT id FROM groups WHERE name = 'Magasin Test'),
|
||||||
|
'TEST-FINAL-001',
|
||||||
|
99.99,
|
||||||
|
'Test avec données créées',
|
||||||
|
false,
|
||||||
|
'admin'
|
||||||
|
) RETURNING id, supplier_id, group_id, created_by;
|
||||||
|
|
||||||
|
-- 5. Nettoyer le test
|
||||||
|
DELETE FROM avoirs WHERE invoice_reference = 'TEST-FINAL-001';
|
||||||
Reference in new issue
Block a user