diff --git a/db/install.js b/db/install.js index 5b2da33..b058f83 100644 --- a/db/install.js +++ b/db/install.js @@ -71,9 +71,7 @@ const drop = async () => { console.log('La tabla TipoUsuario se desinstalo correctamente.'.magenta) await CarreraPlantel.drop() - console.log( - 'La tabla CarreraPlantel se desinstalo correctamente.'.magenta - ) + console.log('La tabla CarreraPlantel se desinstalo correctamente.'.magenta) await Carrera.drop() console.log('La tabla Carrera se desinstalo correctamente.'.magenta) @@ -92,9 +90,7 @@ const sync = async () => { console.log('La tabla Plantel se instalo correctamente.'.magenta) await CarreraPlantel.sync() - console.log( - 'La tabla CarreraPlantel se instalo correctamente.'.magenta - ) + console.log('La tabla CarreraPlantel se instalo correctamente.'.magenta) await TipoUsuario.sync() console.log('La tabla TipoUsuario se instalo correctamente.'.magenta) @@ -145,10 +141,118 @@ const sync = async () => { console.log('La tabla Multa se instalo correctamente.'.magenta) } +const dataTipoCarrito = async () => { + const data = ['Chromebook', 'iPad'] + + console.log('\nInstalando catalogo tipo_carrito'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el registro ${data[i]}`.magenta) + await TipoCarrito.create({ nombre: data[i] }) + } +} + +const dataTipoMulta = async () => { + const data = ['Servicio', 'Red'] + + console.log('\nInstalando catalogo tipo_Multa'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el registro ${data[i]}`.magenta) + await TipoMulta.create({ nombre: data[i] }) + } +} + +const dataTipoOperador = async () => { + const data = ['admin', 'operador'] + + console.log('\nInstalando catalogo tipo_operador'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el registro ${data[i]}`.magenta) + await TipoOperador.create({ nombre: data[i] }) + } +} + +const dataTipoUsuario = async () => { + const data = [ + 'alumno_interno', + 'alumno_externo', + 'profesor_interno', + 'profesor_externo', + ] + + console.log('\nInstalando catalogo tipo_usuario'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el registro ${data[i]}`.magenta) + await TipoUsuario.create({ nombre: data[i] }) + } +} + +const dataStatus = async () => { + const data = ['Activo', 'Mantenimiento', 'DaƱado', 'Cargando'] + + console.log('\nInstalando catalogo Status'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el registro ${data[i]}`.magenta) + await Status.create({ status: data[i] }) + } +} + +const dataMesa = async () => { + console.log('\nInstalando catalogo Mesa'.bold.blue) + for (let i = 1; i <= 150; i++) { + console.log(`Se ha creado la mesa ${i}`.magenta) + await Mesa.create({}) + } +} + +const dataSalon = async () => { + const data = ['nombreUno', 'nombreDos', 'nombreTres'] + + console.log('\nInstalando catalogo Salon'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el Salon ${data[i]}`.magenta) + await Salon.create({ salon: data[i] }) + } +} + +const dataHorario = async () => { + const data = [ + '8:00-10:00', + '10:00-12:00', + '12:00-14:00', + '14:00-16:00', + '16:00-18:00', + '18:00-20:00', + ] + + console.log('\nInstalando catalogo Horario'.bold.blue) + for (let i = 0; i < data.length; i++) { + console.log(`Se ha creado el Horario ${data[i]}`.magenta) + await Horario.create({ horario: data[i] }) + } +} + +// Horario + +// Parte +// Carrito +// Equipo +// Carrera +// CarreraPlantel +// Plantel + const install = async () => { await drop() await sync() + await dataTipoCarrito() + await dataTipoMulta() + await dataTipoUsuario() + await dataTipoOperador() + await dataStatus() + await dataMesa() + await dataSalon() + await dataHorario() + console.log( '\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green ) diff --git a/db/tables/CarreraPlantel.js b/db/tables/CarreraPlantel.js index a72f1aa..29d7c45 100644 --- a/db/tables/CarreraPlantel.js +++ b/db/tables/CarreraPlantel.js @@ -38,4 +38,7 @@ CarreraPlantel.init( } ) +CarreraPlantel.belongsTo(Carrera, { foreignKey: 'idCarrera' }) +CarreraPlantel.belongsTo(Plantel, { foreignKey: 'idPlantel' }) + module.exports = CarreraPlantel diff --git a/db/tables/Mesa.js b/db/tables/Mesa.js index 02a43f2..e8f589d 100644 --- a/db/tables/Mesa.js +++ b/db/tables/Mesa.js @@ -12,10 +12,10 @@ Mesa.init( autoIncrement: true, unique: true, }, - mesa: { - type: DataTypes.STRING(50), - allowNull: false, - }, + // mesa: { + // type: DataTypes.STRING(50), + // allowNull: false, + // }, activo: { type: DataTypes.BOOLEAN, defaultValue: false, @@ -27,7 +27,7 @@ Mesa.init( key: 'idStatus', }, allowNull: false, - // defaultValue: 1, + defaultValue: 1, }, }, { diff --git a/db/tables/Prestamo.js b/db/tables/Prestamo.js index 49c0cf5..e3f5896 100644 --- a/db/tables/Prestamo.js +++ b/db/tables/Prestamo.js @@ -44,7 +44,6 @@ Prestamo.init( key: 'idOperador', }, allowNull: true, - defaultValue: NULL, }, idOperadorRegreso: { type: DataTypes.INTEGER, @@ -53,7 +52,6 @@ Prestamo.init( key: 'idOperador', }, allowNull: true, - defaultValue: NULL, }, idEquipo: { type: DataTypes.INTEGER, @@ -62,7 +60,6 @@ Prestamo.init( key: 'idEquipo', }, allowNull: true, - defaultValue: NULL, }, idHorario: { type: DataTypes.INTEGER, @@ -79,7 +76,6 @@ Prestamo.init( key: 'idMesa', }, allowNull: true, - defaultValue: NULL, }, idSalon: { type: DataTypes.INTEGER, @@ -88,7 +84,6 @@ Prestamo.init( key: 'idSalon', }, allowNull: true, - defaultValue: NULL, }, }, { diff --git a/db/tables/Salon.js b/db/tables/Salon.js index df8595b..7ce3e22 100644 --- a/db/tables/Salon.js +++ b/db/tables/Salon.js @@ -27,13 +27,13 @@ Salon.init( key: 'idStatus', }, allowNull: false, + defaultValue: 1, }, }, { sequelize, modelName: 'Salon', tableName: 'salon', - timestamps: false, } )