mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +02:00
Merge pull request #139 from R0m1k3/claude/fix-notes-sync-issue-01AMeEdrKQErsM7bvhKkqEEF
Claude/fix notes sync issue 01 a me edr kq ers m7bvh kkq eef
This commit is contained in:
3 files changed
+141
-14
No files matched your search
+27
-14
@@ -6,7 +6,29 @@ Erreur 500 sur `/api/notes` - Les notes ne s'affichent pas
|
|||||||
## Cause
|
## Cause
|
||||||
Les données booléennes dans PostgreSQL sont stockées en INTEGER (0/1) au lieu de BOOLEAN (TRUE/FALSE)
|
Les données booléennes dans PostgreSQL sont stockées en INTEGER (0/1) au lieu de BOOLEAN (TRUE/FALSE)
|
||||||
|
|
||||||
## Solution - À exécuter sur note.ffnancy.fr
|
## ✅ Solution AUTOMATIQUE (Recommandée)
|
||||||
|
|
||||||
|
La correction se fait **automatiquement au démarrage de Docker** !
|
||||||
|
|
||||||
|
### Déploiement avec Docker
|
||||||
|
```bash
|
||||||
|
cd /chemin/vers/noteflow
|
||||||
|
git pull origin claude/fix-notes-sync-issue-01AMeEdrKQErsM7bvhKkqEEF
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
Le conteneur Docker va automatiquement:
|
||||||
|
1. Attendre que PostgreSQL soit prêt
|
||||||
|
2. Exécuter les migrations de schéma
|
||||||
|
3. **Corriger automatiquement les types booléens** ✨
|
||||||
|
4. Démarrer le serveur
|
||||||
|
|
||||||
|
C'est tout ! Les notes s'afficheront correctement après le redémarrage.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Solution manuelle (Si vous n'utilisez pas Docker)
|
||||||
|
|
||||||
### Étape 1 : Déployer le nouveau code
|
### Étape 1 : Déployer le nouveau code
|
||||||
```bash
|
```bash
|
||||||
@@ -16,21 +38,12 @@ git pull origin claude/fix-notes-sync-issue-01AMeEdrKQErsM7bvhKkqEEF
|
|||||||
|
|
||||||
### Étape 2 : Exécuter le script de correction
|
### Étape 2 : Exécuter le script de correction
|
||||||
```bash
|
```bash
|
||||||
# Assurez-vous que DATABASE_URL est configuré dans .env
|
# Option A: Script Node.js
|
||||||
node scripts/fix-boolean-data.js
|
node scripts/fix-boolean-data.js
|
||||||
```
|
|
||||||
|
|
||||||
Ce script va:
|
# Option B: Script SQL (plus rapide)
|
||||||
- Vérifier les types des colonnes booléennes
|
psql -U noteflow -d noteflow -f scripts/fix-postgres-boolean-types.sql
|
||||||
- Convertir automatiquement les colonnes INTEGER en BOOLEAN
|
```
|
||||||
- Migrer les données: 0 → FALSE, 1 → TRUE
|
|
||||||
- Corriger ces tables:
|
|
||||||
* users.is_admin
|
|
||||||
* notes.archived
|
|
||||||
* note_todos.completed, note_todos.priority
|
|
||||||
* global_todos.completed, global_todos.priority
|
|
||||||
* rss_feeds.enabled
|
|
||||||
* calendar_events.all_day
|
|
||||||
|
|
||||||
### Étape 3 : Redémarrer le serveur
|
### Étape 3 : Redémarrer le serveur
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -83,6 +83,29 @@ echo ""
|
|||||||
echo "🔄 Migration des timezones du calendrier..."
|
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"
|
node scripts/migrate-calendar-timezone.js 2>/dev/null || echo " ℹ️ Migration timezone déjà effectuée ou non nécessaire"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🔧 Correction des types booléens PostgreSQL..."
|
||||||
|
# Exécuter le script SQL de correction des types booléens
|
||||||
|
if [ -f "/app/scripts/fix-postgres-boolean-types.sql" ]; then
|
||||||
|
# Extraire les informations de connexion depuis DATABASE_URL
|
||||||
|
PGHOST=$(echo $DATABASE_URL | sed -n 's/.*@\([^:]*\):.*/\1/p')
|
||||||
|
PGPORT=$(echo $DATABASE_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
|
||||||
|
PGUSER=$(echo $DATABASE_URL | sed -n 's/.*\/\/\([^:]*\):.*/\1/p')
|
||||||
|
PGPASSWORD=$(echo $DATABASE_URL | sed -n 's/.*:\/\/[^:]*:\([^@]*\)@.*/\1/p')
|
||||||
|
PGDATABASE=$(echo $DATABASE_URL | sed -n 's/.*\/\([^?]*\).*/\1/p')
|
||||||
|
|
||||||
|
export PGHOST PGPORT PGUSER PGPASSWORD PGDATABASE
|
||||||
|
|
||||||
|
# Exécuter le script SQL
|
||||||
|
if psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -f /app/scripts/fix-postgres-boolean-types.sql > /dev/null 2>&1; then
|
||||||
|
echo " ✅ Types booléens corrigés"
|
||||||
|
else
|
||||||
|
echo " ℹ️ Correction des types booléens déjà effectuée ou non nécessaire"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ⚠️ Script de correction non trouvé"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
echo "🚀 Démarrage du serveur NoteFlow..."
|
echo "🚀 Démarrage du serveur NoteFlow..."
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
-- Script de correction des types booléens PostgreSQL
|
||||||
|
-- Convertit les colonnes INTEGER en BOOLEAN et les données 0/1 en FALSE/TRUE
|
||||||
|
-- Ce script est idempotent: il peut être exécuté plusieurs fois sans problème
|
||||||
|
|
||||||
|
-- Fonction pour vérifier et corriger le type d'une colonne
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
column_info RECORD;
|
||||||
|
BEGIN
|
||||||
|
-- Corriger users.is_admin
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'users' AND column_name = 'is_admin';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting users.is_admin from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE users ALTER COLUMN is_admin TYPE BOOLEAN
|
||||||
|
USING CASE WHEN is_admin = 0 THEN FALSE WHEN is_admin = 1 THEN TRUE ELSE is_admin::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger notes.archived
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'notes' AND column_name = 'archived';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting notes.archived from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE notes ALTER COLUMN archived TYPE BOOLEAN
|
||||||
|
USING CASE WHEN archived = 0 THEN FALSE WHEN archived = 1 THEN TRUE ELSE archived::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger note_todos.completed
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'note_todos' AND column_name = 'completed';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting note_todos.completed from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE note_todos ALTER COLUMN completed TYPE BOOLEAN
|
||||||
|
USING CASE WHEN completed = 0 THEN FALSE WHEN completed = 1 THEN TRUE ELSE completed::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger note_todos.priority
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'note_todos' AND column_name = 'priority';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting note_todos.priority from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE note_todos ALTER COLUMN priority TYPE BOOLEAN
|
||||||
|
USING CASE WHEN priority = 0 THEN FALSE WHEN priority = 1 THEN TRUE ELSE priority::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger global_todos.completed
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'global_todos' AND column_name = 'completed';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting global_todos.completed from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE global_todos ALTER COLUMN completed TYPE BOOLEAN
|
||||||
|
USING CASE WHEN completed = 0 THEN FALSE WHEN completed = 1 THEN TRUE ELSE completed::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger global_todos.priority
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'global_todos' AND column_name = 'priority';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting global_todos.priority from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE global_todos ALTER COLUMN priority TYPE BOOLEAN
|
||||||
|
USING CASE WHEN priority = 0 THEN FALSE WHEN priority = 1 THEN TRUE ELSE priority::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger rss_feeds.enabled
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'rss_feeds' AND column_name = 'enabled';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting rss_feeds.enabled from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE rss_feeds ALTER COLUMN enabled TYPE BOOLEAN
|
||||||
|
USING CASE WHEN enabled = 0 THEN FALSE WHEN enabled = 1 THEN TRUE ELSE enabled::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Corriger calendar_events.all_day
|
||||||
|
SELECT data_type INTO column_info FROM information_schema.columns
|
||||||
|
WHERE table_name = 'calendar_events' AND column_name = 'all_day';
|
||||||
|
|
||||||
|
IF FOUND AND column_info.data_type = 'integer' THEN
|
||||||
|
RAISE NOTICE 'Converting calendar_events.all_day from INTEGER to BOOLEAN';
|
||||||
|
ALTER TABLE calendar_events ALTER COLUMN all_day TYPE BOOLEAN
|
||||||
|
USING CASE WHEN all_day = 0 THEN FALSE WHEN all_day = 1 THEN TRUE ELSE all_day::BOOLEAN END;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Boolean type correction completed successfully';
|
||||||
|
END $$;
|
||||||
Reference in new issue
Block a user