const { Pool } = require('pg'); const pool = new Pool({ connectionString: 'postgresql://edumanager:EduManager2026!Seguro@localhost:5432/edumanager' }); async function run() { try { const res = await pool.query(` UPDATE alunos a SET data_nascimento = (s.elem->>'data_nascimento')::timestamp, rg = s.elem->>'rg', rua = s.elem->>'rua', numero = s.elem->>'numero', bairro = s.elem->>'bairro', cidade = s.elem->>'cidade', estado = s.elem->>'estado', cep = s.elem->>'cep' FROM ( SELECT jsonb_array_elements(data->'students') as elem FROM school_data WHERE id = 1 ) s WHERE a.id = s.elem->>'id' RETURNING a.nome; `); console.log(`Sucesso! ${res.rowCount} alunos atualizados diretamente no PostgreSQL.`); } catch (error) { console.error('Erro na migração:', error); } finally { pool.end(); } } run();