mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-11 17:29:37 +02:00
Docs: Quick start PostgreSQL migration
Ajout des outils de migration et documentation: - scripts/verify-postgres-connection.js: Test connexion PostgreSQL - scripts/run-migration.sh: Script automatique de migration - docker-compose.yml: Volume mount pour accès SQLite depuis container - MIGRATION-STEPS.md: Guide pas-à-pas complet de migration La migration peut maintenant être lancée avec: docker-compose build notes-app docker-compose up -d bash scripts/run-migration.sh
This commit is contained in:
4 files changed
+289
No files matched your search
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script de migration SQLite → PostgreSQL
|
||||
# À exécuter depuis le host où Docker tourne
|
||||
|
||||
echo "🔄 Migration SQLite → PostgreSQL"
|
||||
echo "================================"
|
||||
echo ""
|
||||
|
||||
# Vérifier que les containers tournent
|
||||
if ! docker ps | grep -q "noteflow-postgres"; then
|
||||
echo "❌ Container PostgreSQL non trouvé. Lancez: docker-compose up -d"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker ps | grep -q "notes-todo-app"; then
|
||||
echo "❌ Container notes-todo-app non trouvé. Lancez: docker-compose up -d"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Containers trouvés"
|
||||
echo ""
|
||||
|
||||
# Test de connexion PostgreSQL
|
||||
echo "🔍 Test de connexion PostgreSQL..."
|
||||
docker exec notes-todo-app node scripts/verify-postgres-connection.js
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "❌ Impossible de se connecter à PostgreSQL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📊 Lancement de la migration..."
|
||||
echo ""
|
||||
|
||||
# Exécuter la migration depuis le container notes-todo-app
|
||||
# Le fichier SQLite est monté dans /app/data-sqlite/notes.db
|
||||
docker exec -e SQLITE_PATH=/app/data-sqlite/notes.db notes-todo-app node scripts/migrate-sqlite-to-postgres.js
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "✅ Migration terminée avec succès!"
|
||||
echo ""
|
||||
echo "📋 Prochaines étapes:"
|
||||
echo " 1. Vérifier les articles RSS dans l'interface"
|
||||
echo " 2. Tester la récupération des flux RSS"
|
||||
echo " 3. Supprimer l'ancienne base SQLite (data/notes.db) si tout fonctionne"
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Erreur lors de la migration"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,44 @@
|
||||
const { Pool } = require('pg');
|
||||
|
||||
const DATABASE_URL = process.env.DATABASE_URL || 'postgresql://noteflow:noteflow_secure_password_change_me@postgres:5499/noteflow';
|
||||
|
||||
async function verifyConnection() {
|
||||
const pool = new Pool({
|
||||
connectionString: DATABASE_URL,
|
||||
max: 1,
|
||||
connectionTimeoutMillis: 5000,
|
||||
});
|
||||
|
||||
try {
|
||||
console.log('🔍 Test de connexion PostgreSQL...');
|
||||
console.log('📍 URL:', DATABASE_URL.replace(/:[^:@]+@/, ':***@'));
|
||||
|
||||
const client = await pool.connect();
|
||||
console.log('✅ Connexion PostgreSQL réussie!');
|
||||
|
||||
// Vérifier les tables existantes
|
||||
const tables = await client.query(`
|
||||
SELECT tablename FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
ORDER BY tablename
|
||||
`);
|
||||
|
||||
console.log('\n📋 Tables existantes:', tables.rows.length);
|
||||
tables.rows.forEach(row => console.log(' -', row.tablename));
|
||||
|
||||
// Vérifier les articles RSS si la table existe
|
||||
if (tables.rows.some(r => r.tablename === 'rss_articles')) {
|
||||
const count = await client.query('SELECT COUNT(*) FROM rss_articles');
|
||||
console.log('\n📰 Articles RSS:', count.rows[0].count);
|
||||
}
|
||||
|
||||
client.release();
|
||||
await pool.end();
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
verifyConnection();
|
||||
Reference in new issue
Block a user