const { Pool } = require('pg'); async function run() { const pool = new Pool({ connectionString: 'postgresql://postgres:postgres@localhost:5432/xflow' }); const canvasId = 'xflow-project'; const res = await pool.query('SELECT * FROM "Canvas" WHERE id = $1', [canvasId]); if (res.rowCount === 0) { console.error('Canvas xflow-project not found in DB'); await pool.end(); return; } const canvas = res.rows[0]; let nodes = typeof canvas.nodes === 'string' ? JSON.parse(canvas.nodes) : canvas.nodes; let edges = typeof canvas.edges === 'string' ? JSON.parse(canvas.edges) : canvas.edges; // Find a good spot for new nodes. Usually far to the right or bottom. // Let's put them near the "Future Development" node if it exists. const futureNode = nodes.find(n => n.id === 'future-1') || { x: 500, y: 500 }; const startX = futureNode.x + 400; const startY = futureNode.y; const newNodes = [ { id: 'session-28-04', type: 'text', x: startX, y: startY, width: 400, height: 200, text: '# 🎉 Итоги сессии 28.04\n\nСегодня мы значительно продвинули XFlow вперед, решив критические проблемы синхронизации и внедрив новые функции управления.', style: { background: '#064e3b', border: '#10b981' } }, { id: 'task-sync-fix', type: 'task', x: startX + 450, y: startY - 100, width: 300, height: 150, text: '### Синхронизация Метаданных\n\nИсправлена потеря данных при сохранении. Поля `assigned_to`, `priority`, `alarm` теперь сохраняются надежно.', state: 'completed', assigned_to: 'almalexyz', priority: 'high' }, { id: 'task-kanban-fix', type: 'task', x: startX + 450, y: startY + 100, width: 300, height: 150, text: '### Канбан-доска\n\nЦентрализованный вид всех задач со всех карт. Исправлена фильтрация по пользователю.', state: 'completed', assigned_to: 'almalexyz', priority: 'high' }, { id: 'task-auth-fix', type: 'task', x: startX + 450, y: startY + 300, width: 300, height: 150, text: '### Миграция ID и Прав\n\nИсправлены 403/404 ошибки. Синхронизированы Firebase ID и Prisma ID.', state: 'completed', assigned_to: 'almalexyz', priority: 'high' } ]; const newEdges = [ { id: 'e-session-1', source: 'future-1', target: 'session-28-04' }, { id: 'e-session-2', source: 'session-28-04', target: 'task-sync-fix' }, { id: 'e-session-3', source: 'session-28-04', target: 'task-kanban-fix' }, { id: 'e-session-4', source: 'session-28-04', target: 'task-auth-fix' } ]; // Merge nodes = [...nodes, ...newNodes]; edges = [...edges, ...newEdges]; await pool.query( 'UPDATE "Canvas" SET nodes = $1, edges = $2, "updatedAt" = NOW() WHERE id = $3', [JSON.stringify(nodes), JSON.stringify(edges), canvasId] ); console.log('Successfully merged session results into xflow-project'); await pool.end(); } run().catch(console.error);