ÿØÿà JFIF ` ` ÿþ
|
Server : Apache System : Linux cloud.heroica.com.br 4.18.0-553.36.1.el8_10.x86_64 #1 SMP Wed Jan 22 03:07:54 EST 2025 x86_64 User : farolpborg ( 1053) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /var/www/node_services/apicentralquestoes/src/scripts/ |
Upload File : |
const sequelize = require("../database");
const truncateDatabase = async () => {
try {
console.log("Iniciando truncamento do banco de dados...");
await sequelize.query("SET FOREIGN_KEY_CHECKS = 0");
const tables = await sequelize.query("SHOW TABLES", {
type: sequelize.QueryTypes.SHOWTABLES,
});
for (const table of tables) {
await sequelize.query(`TRUNCATE TABLE ${table}`);
console.log(`Tabela ${table} truncada.`);
}
await sequelize.query("SET FOREIGN_KEY_CHECKS = 1");
console.log("Banco de dados truncado com sucesso.");
} catch (error) {
console.error("Erro ao truncar o banco de dados:", error);
} finally {
await sequelize.close();
console.log("Conexão com o banco de dados fechada.");
}
};
truncateDatabase();