diff --git a/db/tablas/Alumno.js b/db/tablas/Alumno.js new file mode 100644 index 0000000..1f0b684 --- /dev/null +++ b/db/tablas/Alumno.js @@ -0,0 +1,45 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class Alumno extends Model {} +Alumno.init( + { + idAlumno: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + numeroCuenta: { + type: DataTypes.STRING(10), + allowNull: false, + unique: true, + }, + fechaNacimiento: { + type: DataTypes.DATE, + allowNull: false, + }, + nombre: { + type: DataTypes.STRING(30), + allowNull: false, + }, + apellidoMaterno: { + type: DataTypes.STRING(30), + allowNull: false, + }, + apellidoPaterno: { + type: DataTypes.STRING(30), + allowNull: false, + } + }, + { + sequelize, + modelName: 'Alumno', + tableName: 'alumno', + timestamps: false, + } +); + + +module.exports = Alumno; diff --git a/db/tablas/Carrera.js b/db/tablas/Carrera.js new file mode 100644 index 0000000..ef4a133 --- /dev/null +++ b/db/tablas/Carrera.js @@ -0,0 +1,27 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class Carrera extends Model {} +Carrera.init( + { + idCarrera: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + carrera: { + type: DataTypes.STRING(50), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Carrera', + tableName: 'carrera', + timestamps: false, + } +); + +module.exports = Carrera; diff --git a/db/tablas/CarreraPeriodo.js b/db/tablas/CarreraPeriodo.js new file mode 100644 index 0000000..c8f10e0 --- /dev/null +++ b/db/tablas/CarreraPeriodo.js @@ -0,0 +1,46 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const Carrera = require('./Carrera'); +const Periodo = require('./Periodo'); + +class CarreraPeriodo extends Model {} +CarreraPeriodo.init( + { + idCarreraPeriodo: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + vistoBueno: { + type: DataTypes.BOOLEAN, + allowNull: true, + defaultValue: false + } + }, + { + sequelize, + modelName: 'CarreraPeriodo', + tableName: 'carrera_periodo', + timestamps: false, + } +); + +CarreraPeriodo.belongsTo(Carrera, { + foreignKey: { + name: 'idCarrera', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +CarreraPeriodo.belongsTo(Periodo, { + foreignKey: { + name: 'idPeriodo', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = CarreraPeriodo; diff --git a/db/tablas/CarreraPeriodoGrupo.js b/db/tablas/CarreraPeriodoGrupo.js new file mode 100644 index 0000000..593c3a1 --- /dev/null +++ b/db/tablas/CarreraPeriodoGrupo.js @@ -0,0 +1,41 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const CarreraPeriodo = require('./CarreraPeriodo'); +const Grupo = require('./Grupo'); + +class CarreraPeriodoGrupo extends Model {} +CarreraPeriodoGrupo.init( + { + idCarreraPeriodoGrupo: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + } + }, + { + sequelize, + modelName: 'CarreraPeriodoGrupo', + tableName: 'carrera_periodo_grupo', + timestamps: false, + } +); + +CarreraPeriodoGrupo.belongsTo(CarreraPeriodo, { + foreignKey: { + name: 'idCarreraPeriodo', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +CarreraPeriodoGrupo.belongsTo(Grupo, { + foreignKey: { + name: 'idGrupo', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = CarreraPeriodoGrupo; diff --git a/db/tablas/Cuestionario.js b/db/tablas/Cuestionario.js new file mode 100644 index 0000000..af3d7fe --- /dev/null +++ b/db/tablas/Cuestionario.js @@ -0,0 +1,60 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const TipoCuestionario = require('./TipoCuestionario'); +const Usuario = require('./Usuario'); + + +class Cuestionario extends Model {} +Cuestionario.init( + { + idCuestionario: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + fechaInicio: { + type: DataTypes.DATE, + allowNull: false, + }, + fechaFin: { + type: DataTypes.DATE, + allowNull: false, + }, + titulo: { + type: DataTypes.STRING(100), + allowNull: false, + }, + descripcion: { + type: DataTypes.STRING(100), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Cuestionario', + tableName: 'cuestionario', + timestamps: true, + createdAt: true, + updatedAt: false, + } +); + +Cuestionario.belongsTo(Usuario, { + foreignKey: { + name: 'idUsuario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +Cuestionario.belongsTo(TipoCuestionario, { + foreignKey: { + name: 'idTipoCuestionario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = Cuestionario; diff --git a/db/tablas/CuestionarioCarrera.js b/db/tablas/CuestionarioCarrera.js new file mode 100644 index 0000000..8e12b05 --- /dev/null +++ b/db/tablas/CuestionarioCarrera.js @@ -0,0 +1,41 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const Carrera = require('./Carrera'); +const Cuestionario = require('./Cuestionario'); + +class CuestionarioCarrera extends Model {} +CuestionarioCarrera.init( + { + idCuestionarioCarrera: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + }, + { + sequelize, + modelName: 'CuestionarioCarrera', + tableName: 'cuestionario_carrera', + timestamps: false, + } +); + +CuestionarioCarrera.belongsTo(Carrera, { + foreignKey: { + name: 'idCarrera', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +CuestionarioCarrera.belongsTo(Cuestionario, { + foreignKey: { + name: 'idCuestionario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = CuestionarioCarrera; diff --git a/db/tablas/Grupo.js b/db/tablas/Grupo.js new file mode 100644 index 0000000..0311942 --- /dev/null +++ b/db/tablas/Grupo.js @@ -0,0 +1,27 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class Grupo extends Model {} +Grupo.init( + { + idGrupo: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + grupo: { + type: DataTypes.STRING(10), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Grupo', + tableName: 'grupo', + timestamps: false, + } +); + +module.exports = Grupo; diff --git a/db/tablas/GrupoMateria.js b/db/tablas/GrupoMateria.js new file mode 100644 index 0000000..03421a8 --- /dev/null +++ b/db/tablas/GrupoMateria.js @@ -0,0 +1,50 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const CarreraPeriodoGrupo = require('./CarreraPeriodoGrupo'); +const Materia = require('./Materia'); +const Trabajador = require('./Trabajador'); + +class GrupoMateria extends Model {} +GrupoMateria.init( + { + idGrupoMateria: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + }, + { + sequelize, + modelName: 'GrupoMateria', + tableName: 'grupo_materia', + timestamps: false, + } +); + +GrupoMateria.belongsTo(CarreraPeriodoGrupo, { + foreignKey: { + name: 'idCarreraPeriodoGrupo', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +GrupoMateria.belongsTo(Trabajador, { + foreignKey: { + name: 'idProfesor', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +GrupoMateria.belongsTo(Materia, { + foreignKey: { + name: 'idMateria', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = GrupoMateria; diff --git a/db/tablas/Materia.js b/db/tablas/Materia.js new file mode 100644 index 0000000..3fc708f --- /dev/null +++ b/db/tablas/Materia.js @@ -0,0 +1,27 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class Materia extends Model {} +Materia.init( + { + idMateria: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + materia: { + type: DataTypes.STRING(100), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Materia', + tableName: 'materia', + timestamps: false, + } +); + +module.exports = Materia; diff --git a/db/tablas/Periodo.js b/db/tablas/Periodo.js new file mode 100644 index 0000000..13af3b1 --- /dev/null +++ b/db/tablas/Periodo.js @@ -0,0 +1,31 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class Periodo extends Model {} +Periodo.init( + { + idPeriodo: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + periodo: { + type: DataTypes.STRING(15), + allowNull: false, + }, + activo: { + type: DataTypes.BOOLEAN, + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Periodo', + tableName: 'periodo', + timestamps: false, + } +); + +module.exports = Periodo; diff --git a/db/tablas/Seccion.js b/db/tablas/Seccion.js new file mode 100644 index 0000000..db0ff06 --- /dev/null +++ b/db/tablas/Seccion.js @@ -0,0 +1,41 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const Cuestionario = require('./Cuestionario'); + +class Seccion extends Model {} +Seccion.init( + { + idSeccion: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + titulo: { + type: DataTypes.STRING(100), + allowNull: false, + }, + descripcion: { + type: DataTypes.STRING(100), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Seccion', + tableName: 'seccion', + timestamps: false, + } +); + +Seccion.belongsTo(Cuestionario, { + foreignKey: { + name: 'idCuestionario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + + +module.exports = Seccion; diff --git a/db/tablas/TipoCuestionario.js b/db/tablas/TipoCuestionario.js new file mode 100644 index 0000000..cc1f0c8 --- /dev/null +++ b/db/tablas/TipoCuestionario.js @@ -0,0 +1,27 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class TipoCuestionario extends Model {} +TipoCuestionario.init( + { + idTipoCuestionario: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + tipoCuestionario: { + type: DataTypes.STRING(50), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'TipoCuestionario', + tableName: 'tipo_cuestionario', + timestamps: false, + } +); + +module.exports = TipoCuestionario; diff --git a/db/tablas/TipoPregunta.js b/db/tablas/TipoPregunta.js new file mode 100644 index 0000000..e428158 --- /dev/null +++ b/db/tablas/TipoPregunta.js @@ -0,0 +1,27 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class TipoPregunta extends Model {} +TipoPregunta.init( + { + idTipoPregunta: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + tipoPregunta: { + type: DataTypes.STRING(50), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'TipoPregunta', + tableName: 'tipo_pregunta', + timestamps: false, + } +); + +module.exports = TipoPregunta; diff --git a/db/tablas/Trabajador.js b/db/tablas/Trabajador.js new file mode 100644 index 0000000..3e1d7ef --- /dev/null +++ b/db/tablas/Trabajador.js @@ -0,0 +1,57 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const TipoUsuario = require('./TipoUsuario'); + +class Trabajador extends Model {} +Trabajador.init( + { + idTrabajador: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + numeroTrabajador: { + type: DataTypes.STRING(20), + allowNull: false, + unique: true, + }, + nombre: { + type: DataTypes.STRING(30), + allowNull: false, + }, + apellidoMaterno: { + type: DataTypes.STRING(30), + allowNull: false, + }, + apellidoPaterno: { + type: DataTypes.STRING(30), + allowNull: false, + }, + rfc: { + type: DataTypes.STRING(7), + allowNull: false, + }, + homoclave: { + type: DataTypes.STRING(3), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Trabajador', + tableName: 'trabajador', + timestamps: false, + } +); + +Trabajador.belongsTo(TipoUsuario, { + foreignKey: { + name: 'idTipoUsuario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = Trabajador; diff --git a/db/tablas/Usuario.js b/db/tablas/Usuario.js index 4e7660a..84f5181 100644 --- a/db/tablas/Usuario.js +++ b/db/tablas/Usuario.js @@ -22,15 +22,6 @@ Usuario.init( allowNull: true, defaultValue: null, }, - nombre: { - type: DataTypes.STRING(70), - allowNull: true, - defaultValue: null, - }, - activo: { - type: DataTypes.BOOLEAN, - allowNull: false, - }, }, { sequelize, diff --git a/db/tablas/UsuarioCarrera.js b/db/tablas/UsuarioCarrera.js new file mode 100644 index 0000000..561edd5 --- /dev/null +++ b/db/tablas/UsuarioCarrera.js @@ -0,0 +1,41 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); +const Carrera = require('./Carrera'); +const Usuario = require('./Usuario'); + +class UsuarioCarrera extends Model {} +UsuarioCarrera.init( + { + idUsuarioCarrera: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + }, + { + sequelize, + modelName: 'UsuarioCarrera', + tableName: 'usuario_carrera', + timestamps: false, + } +); + +UsuarioCarrera.belongsTo(Carrera, { + foreignKey: { + name: 'idCarrera', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +UsuarioCarrera.belongsTo(Usuario, { + foreignKey: { + name: 'idUsuario', + type: DataTypes.INTEGER, + allowNull: false, + }, +}); + +module.exports = UsuarioCarrera;