const logSymbols = require("log-symbols"); const colors = require("colors"); const bcrypt = require("bcrypt"); const admin = require("./tablas/Admin"); require("../config/config"); async function remove() { console.log(logSymbols.info, "Paso 1 : Borrando base de datos \n".blue.bold); await admin.drop(); console.log(logSymbols.success, "admin"); } async function install() { console.log( logSymbols.info, "Paso 2 : Instalando base de datos \n".blue.bold ); await admin.sync(); console.log(logSymbols.success, "admin"); //crear clave foranea de una tabla a otra, ejemplo // responsable.hasMany(programa, { // foreignKey: "idResponsable", // }); }; async function createFirstUsers() { console.log( logSymbols.info, "Paso 3 : Creating first users in database...\n".blue.bold ); await admin.create({ name: 'alima', password: bcrypt.hashSync('contraseña', 10), isAdmin: true }); await admin.create({ name: 'alfredojl', password: bcrypt.hashSync('contraseña', 10), isAdmin: false }); } async function exec() { await remove(); await install(); await createFirstUsers(); console.log(logSymbols.success, "Éxito al instalar \n".underline.bold.green); process.exit(); } exec();