Login
This commit is contained in:
+40
-19
@@ -7,35 +7,56 @@ const admin = require("./tablas/Admin");
|
||||
require("../config/config");
|
||||
|
||||
async function remove() {
|
||||
console.log(logSymbols.info, "Paso 1 : Borrando base de datos \n".blue.bold);
|
||||
console.log(logSymbols.info, "Paso 1 : Borrando base de datos \n".blue.bold);
|
||||
|
||||
await admin.drop();
|
||||
console.log(logSymbols.success, "admin");
|
||||
await admin.drop();
|
||||
console.log(logSymbols.success, "admin");
|
||||
|
||||
}
|
||||
|
||||
async function install() {
|
||||
console.log(
|
||||
logSymbols.info,
|
||||
"Paso 2 : Instalando base de datos \n".blue.bold
|
||||
);
|
||||
console.log(
|
||||
logSymbols.info,
|
||||
"Paso 2 : Instalando base de datos \n".blue.bold
|
||||
);
|
||||
|
||||
await admin.sync();
|
||||
console.log(logSymbols.success, "admin");
|
||||
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
|
||||
});
|
||||
|
||||
//crear clave foranea de una tabla a otra, ejemplo
|
||||
// responsable.hasMany(programa, {
|
||||
// foreignKey: "idResponsable",
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
async function exec() {
|
||||
await remove();
|
||||
await install();
|
||||
await remove();
|
||||
await install();
|
||||
await createFirstUsers();
|
||||
|
||||
console.log(logSymbols.success, "Éxito al instalar \n".underline.bold.green);
|
||||
process.exit();
|
||||
console.log(logSymbols.success, "Éxito al instalar \n".underline.bold.green);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
exec();
|
||||
exec();
|
||||
Reference in New Issue
Block a user