Merge pull request #177 from R0m1k3/1.1

Fix error when accessing announcements and update production scripts
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-16 14:06:01 +02:00
commit e39d25c315
3 files changed
+224 -42

No files matched your search

@@ -0,0 +1,205 @@
Actions
GET /api/dlc-products/stats 200 in 302ms
🔗 PRODUCTION: getOrders() récupéré 51 commandes avec relations
Orders returned: 51 items
GET /api/orders 200 in 434ms
GET /api/groups 200 in 346ms
🌤️ [RESPONSE] Weather data prepared: {
hasCurrentYear: true,
hasPreviousYear: true,
location: 'Frouard, France'
}
GET /api/weather/current 200 in 446ms
📊 Statistiques calculées: {
ordersCount: 20,
deliveriesCount: 42,
pendingOrdersCount: 8,
averageDeliveryTime: 0.3611111111111111,
totalPalettes: 120,
totalPackages: 36
}
GET /api/stats/monthly 200 in 444ms
Orders API called with: {
startDate: undefined,
endDate: undefined,
storeId: '1',
userRole: 'admin'
}
Admin filtering with groupIds: [ 1 ]
Fetching all orders
Customer Orders API called with: { groupIds: [ 1 ], userRole: 'admin' }
Deliveries API called with: {
startDate: undefined,
endDate: undefined,
storeId: '1',
withBL: undefined,
userRole: 'admin'
}
Admin filtering deliveries with groupIds: [ 1 ]
Fetching all deliveries
🔗 PRODUCTION: getDeliveries() récupéré 86 livraisons avec relations
Deliveries returned: 86 items
GET /api/deliveries 200 in 455ms
Customer Orders returned: 10 items
GET /api/customer-orders 200 in 132ms
🔗 PRODUCTION: getOrders() récupéré 33 commandes avec relations
Orders returned: 33 items
GET /api/orders 200 in 295ms
🔗 PRODUCTION: getDeliveries() récupéré 48 livraisons avec relations
Deliveries returned: 48 items
GET /api/deliveries 200 in 248ms
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 11ms
HEAD /api/health 200 in 1ms
+7 -11
View File
@@ -1,30 +1,26 @@
-- Script pour créer la table announcements en production -- Script SQL simple pour créer UNIQUEMENT la table announcements en production
-- Exécuter avec : psql -d votre_base -f create_announcements_production.sql -- À exécuter directement dans le conteneur Docker
-- Création de la table announcements
CREATE TABLE IF NOT EXISTS announcements ( CREATE TABLE IF NOT EXISTS announcements (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
content TEXT NOT NULL, content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal' CHECK (priority IN ('normal', 'important', 'urgent')), priority VARCHAR(20) NOT NULL DEFAULT 'normal',
author_id VARCHAR(255) NOT NULL, author_id VARCHAR(255) NOT NULL,
group_id INTEGER, group_id INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_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_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 CONSTRAINT announcements_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE
); );
-- Création des index -- Créer les index pour les performances
CREATE INDEX IF NOT EXISTS idx_announcements_priority ON announcements(priority); 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_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_author_id ON announcements(author_id);
CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id); CREATE INDEX IF NOT EXISTS idx_announcements_group_id ON announcements(group_id);
-- Commentaires
COMMENT ON TABLE announcements IS 'Admin-managed announcements/information system';
COMMENT ON COLUMN announcements.priority IS 'Priority level: normal, important, urgent';
COMMENT ON COLUMN announcements.group_id IS 'NULL for global announcements, specific group_id for store-specific announcements';
-- Vérification -- Vérification
SELECT 'Table announcements créée avec succès!' as message; SELECT 'Table announcements créée avec succès' as resultat;
SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'announcements' ORDER BY ordinal_position;
Regular → Executable
+12 -31
View File
@@ -1,38 +1,19 @@
#!/bin/bash #!/bin/bash
# Script de correction urgente pour la production # Script d'urgence pour corriger la production immédiatement
# Exécuter depuis votre serveur de production
echo "🔧 Correction urgente pour la table announcements..." echo "🚨 CORRECTION URGENTE - Création de la table announcements"
# Création de la table via commande SQL directe # Option 1: Copier le fichier SQL dans le conteneur et l'exécuter
docker exec logiflow-logiflow-1 psql "$DATABASE_URL" -c " echo "📋 Copie du script SQL dans le conteneur..."
CREATE TABLE IF NOT EXISTS announcements ( docker cp create_announcements_production.sql logiflow-logiflow-1:/tmp/
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
priority VARCHAR(20) NOT NULL DEFAULT 'normal' CHECK (priority IN ('normal', 'important', 'urgent')),
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_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); echo "🔧 Exécution du script SQL..."
CREATE INDEX IF NOT EXISTS idx_announcements_created_at ON announcements(created_at DESC); docker exec logiflow-logiflow-1 psql $DATABASE_URL -f /tmp/create_announcements_production.sql
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);
COMMENT ON TABLE announcements IS 'Admin-managed announcements/information system'; echo "✅ Script exécuté. Vérification..."
" docker exec logiflow-logiflow-1 psql $DATABASE_URL -c "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name='announcements') as table_exists;"
# Vérification de la création echo "🎯 Redémarrage de l'application..."
echo "🔍 Vérification de la table..." docker restart logiflow-logiflow-1
docker exec logiflow-logiflow-1 psql "$DATABASE_URL" -c "
SELECT 'SUCCESS: Table announcements créée!' as status
FROM information_schema.tables
WHERE table_name = 'announcements';
"
echo "✅ Script terminé!" echo "✅ CORRECTION TERMINÉE"