Merge pull request #87 from R0m1k3/claude/update-rss-feeds-011CV6EZDsWAUqbRHZR1117Q

Fix: Décalage horaire Google Calendar (+1h corrigé)
This commit is contained in:
LogiFlow authored and GitHub committed 2025-11-14 11:54:48 +01:00
commit debf4fc58f
5 files changed
+129 -4

No files matched your search

+2 -2
View File
@@ -168,8 +168,8 @@ async function initDatabase() {
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
title TEXT NOT NULL,
description TEXT,
start_time TIMESTAMP NOT NULL,
end_time TIMESTAMP NOT NULL,
start_time TIMESTAMPTZ NOT NULL,
end_time TIMESTAMPTZ NOT NULL,
location TEXT,
color_id TEXT,
html_link TEXT,
+4
View File
@@ -75,6 +75,10 @@ else
echo "✅ PostgreSQL contient déjà des données ($HAS_DATA utilisateurs)"
fi
echo ""
echo "🔄 Migration des timezones du calendrier..."
node scripts/migrate-calendar-timezone.js 2>/dev/null || echo " ℹ️ Migration timezone déjà effectuée ou non nécessaire"
echo ""
echo "========================================"
echo "🚀 Démarrage du serveur NoteFlow..."
+24
View File
@@ -0,0 +1,24 @@
-- Migration: Convertir calendar_events TIMESTAMP → TIMESTAMPTZ
-- Pour corriger le décalage horaire de 1h dans l'affichage
BEGIN;
-- Convertir start_time de TIMESTAMP à TIMESTAMPTZ
ALTER TABLE calendar_events
ALTER COLUMN start_time TYPE TIMESTAMPTZ
USING start_time AT TIME ZONE 'UTC';
-- Convertir end_time de TIMESTAMP à TIMESTAMPTZ
ALTER TABLE calendar_events
ALTER COLUMN end_time TYPE TIMESTAMPTZ
USING end_time AT TIME ZONE 'UTC';
COMMIT;
-- Vérification
SELECT
column_name,
data_type
FROM information_schema.columns
WHERE table_name = 'calendar_events'
AND column_name IN ('start_time', 'end_time');
+2 -2
View File
@@ -430,7 +430,7 @@ router.post('/sync', authenticateToken, async (req, res) => {
endTime,
event.location || '',
event.htmlLink || '',
isAllDay ? 1 : 0,
isAllDay,
existing.id
]);
} else {
@@ -448,7 +448,7 @@ router.post('/sync', authenticateToken, async (req, res) => {
endTime,
event.location || '',
event.htmlLink || '',
isAllDay ? 1 : 0
isAllDay
]);
}
syncedCount++;
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env node
// Migration: Convertir calendar_events TIMESTAMP → TIMESTAMPTZ
const { Pool } = require('pg');
const DATABASE_URL = process.env.DATABASE_URL;
if (!DATABASE_URL) {
console.error('❌ DATABASE_URL non définie');
process.exit(1);
}
async function migrate() {
const pool = new Pool({ connectionString: DATABASE_URL });
try {
console.log('\n🔄 Migration: calendar_events TIMESTAMP → TIMESTAMPTZ\n');
const client = await pool.connect();
// Vérifier le type actuel
const check = await client.query(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'calendar_events'
AND column_name IN ('start_time', 'end_time')
`);
console.log('📊 Types actuels:');
check.rows.forEach(row => {
console.log(` ${row.column_name}: ${row.data_type}`);
});
// Si déjà TIMESTAMPTZ, skip
const alreadyMigrated = check.rows.every(row =>
row.data_type.includes('timestamp with time zone') ||
row.data_type === 'timestamptz'
);
if (alreadyMigrated) {
console.log('\n✅ Migration déjà effectuée, rien à faire');
client.release();
await pool.end();
return;
}
console.log('\n🔄 Conversion en cours...');
await client.query('BEGIN');
// Convertir start_time
await client.query(`
ALTER TABLE calendar_events
ALTER COLUMN start_time TYPE TIMESTAMPTZ
USING start_time AT TIME ZONE 'UTC'
`);
console.log(' ✅ start_time → TIMESTAMPTZ');
// Convertir end_time
await client.query(`
ALTER TABLE calendar_events
ALTER COLUMN end_time TYPE TIMESTAMPTZ
USING end_time AT TIME ZONE 'UTC'
`);
console.log(' ✅ end_time → TIMESTAMPTZ');
await client.query('COMMIT');
// Vérifier après migration
const verify = await client.query(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'calendar_events'
AND column_name IN ('start_time', 'end_time')
`);
console.log('\n📊 Types après migration:');
verify.rows.forEach(row => {
console.log(` ${row.column_name}: ${row.data_type}`);
});
console.log('\n✅ Migration terminée avec succès!');
console.log('');
console.log('📝 Note: Resynchronisez vos événements Google Calendar');
console.log(' pour appliquer le nouveau format de timezone.');
console.log('');
client.release();
await pool.end();
} catch (error) {
console.error('\n❌ Erreur lors de la migration:', error.message);
process.exit(1);
}
}
migrate();