mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +02:00
3 files changed
+29
-4
No files matched your search
+11
-4
@@ -12,7 +12,7 @@ const timezoneLogger = require('../services/timezone-logger');
|
||||
// - 1184 = TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ)
|
||||
|
||||
// Parser pour TIMESTAMPTZ (1184)
|
||||
types.setTypeParser(1184, function(stringValue) {
|
||||
types.setTypeParser(1184, function (stringValue) {
|
||||
if (!stringValue) return null;
|
||||
|
||||
const originalValue = stringValue;
|
||||
@@ -38,7 +38,7 @@ types.setTypeParser(1184, function(stringValue) {
|
||||
// mais PostgreSQL les retourne sans fuseau horaire.
|
||||
// Exemple: Google envoie "2025-11-17T10:20:00+01:00" → PG stocke "2025-11-17 10:20:00"
|
||||
// On doit interpréter cette heure comme UTC (car PG a converti lors de l'insertion)
|
||||
types.setTypeParser(1114, function(stringValue) {
|
||||
types.setTypeParser(1114, function (stringValue) {
|
||||
if (!stringValue) return null;
|
||||
|
||||
// PostgreSQL retourne "YYYY-MM-DD HH:MM:SS" sans fuseau horaire
|
||||
@@ -108,6 +108,7 @@ async function initDatabase() {
|
||||
content TEXT,
|
||||
image_filename TEXT,
|
||||
archived BOOLEAN DEFAULT FALSE,
|
||||
archived_at TIMESTAMP,
|
||||
priority INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
@@ -121,7 +122,10 @@ async function initDatabase() {
|
||||
note_id INTEGER NOT NULL REFERENCES notes(id) ON DELETE CASCADE,
|
||||
text TEXT NOT NULL,
|
||||
completed BOOLEAN DEFAULT FALSE,
|
||||
position INTEGER DEFAULT 0
|
||||
priority BOOLEAN DEFAULT FALSE,
|
||||
position INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
completed_at TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
@@ -132,7 +136,10 @@ async function initDatabase() {
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
text TEXT NOT NULL,
|
||||
completed BOOLEAN DEFAULT FALSE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
priority BOOLEAN DEFAULT FALSE,
|
||||
in_progress INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
completed_at TIMESTAMP
|
||||
)
|
||||
`);
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ else
|
||||
echo "✅ PostgreSQL contient déjà des données ($HAS_DATA utilisateurs)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🔄 Vérification des migrations de schéma..."
|
||||
node scripts/auto-migrate.js
|
||||
|
||||
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"
|
||||
|
||||
@@ -167,6 +167,20 @@ async function autoMigrate() {
|
||||
await client.query(`ALTER TABLE note_todos ADD COLUMN priority BOOLEAN DEFAULT FALSE`);
|
||||
}
|
||||
|
||||
// Migration 3: Champ in_progress pour les tâches globales
|
||||
logger.info(' Vérification: champ in_progress pour global_todos...');
|
||||
|
||||
const globalTodosInProgressExists = await client.query(`
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name='global_todos' AND column_name='in_progress'
|
||||
`);
|
||||
|
||||
if (globalTodosInProgressExists.rows.length === 0) {
|
||||
logger.info(' → Ajout du champ in_progress à global_todos');
|
||||
await client.query('ALTER TABLE global_todos ADD COLUMN in_progress INTEGER DEFAULT 0');
|
||||
}
|
||||
|
||||
// Créer les index pour performance
|
||||
await client.query(`CREATE INDEX IF NOT EXISTS idx_global_todos_priority ON global_todos(priority DESC, created_at DESC)`);
|
||||
await client.query(`CREATE INDEX IF NOT EXISTS idx_note_todos_priority ON note_todos(priority DESC, position)`);
|
||||
|
||||
Reference in new issue
Block a user