chore(ops): migrate clube67 to newwhats.clube67.com directory
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function run() {
|
||||
const c = await mysql.createConnection({
|
||||
host: 'localhost', user: 'root', password: '', database: 'sis_odonto'
|
||||
});
|
||||
|
||||
// 1. Seed missing plans (those referenced by existing procedimentos_valores_planos)
|
||||
const plans = [
|
||||
{ id: 'p2', nome: 'UNIMED ODONTO', tipo: 'Convenio', descontoPadrao: 0, corCartao: '#1eb545' },
|
||||
{ id: 'p3', nome: 'ODONTOPREV', tipo: 'Convenio', descontoPadrao: 0, corCartao: '#0066cc' },
|
||||
{ id: 'p4', nome: 'CASSEMS', tipo: 'Convenio', descontoPadrao: 0, corCartao: '#e63946' },
|
||||
{ id: 'p5', nome: 'SESI ODONTO', tipo: 'Convenio', descontoPadrao: 0, corCartao: '#f4a261' },
|
||||
];
|
||||
|
||||
for (const p of plans) {
|
||||
await c.query(
|
||||
'INSERT IGNORE INTO planos (id, nome, tipo, descontoPadrao, corCartao) VALUES (?, ?, ?, ?, ?)',
|
||||
[p.id, p.nome, p.tipo, p.descontoPadrao, p.corCartao]
|
||||
);
|
||||
}
|
||||
console.log('Plans seeded.');
|
||||
|
||||
// 2. Drop the FK on planoId to make the relation soft (plan can be deleted without cascading)
|
||||
// This prevents the ER_NO_REFERENCED_ROW_2 on INSERT
|
||||
try {
|
||||
await c.query('ALTER TABLE procedimentos_valores_planos DROP FOREIGN KEY procedimentos_valores_planos_ibfk_2');
|
||||
console.log('FK on planoId dropped — now soft reference.');
|
||||
} catch (e) {
|
||||
console.log('FK drop skipped (may already not exist):', e.message);
|
||||
}
|
||||
|
||||
const [planos] = await c.query('SELECT id, nome, tipo FROM planos');
|
||||
console.log('\n--- PLANOS FINAIS ---');
|
||||
console.table(planos);
|
||||
|
||||
await c.end();
|
||||
}
|
||||
|
||||
run().catch(console.error);
|
||||
Reference in New Issue
Block a user