43 lines
964 B
JavaScript
43 lines
964 B
JavaScript
const { Model, DataTypes } = require("sequelize");
|
|
const Profesor = require("./Profesor");
|
|
const sequelize = require('../../config/sequelize.conf');
|
|
|
|
class ProfesorInscrito extends Model {}
|
|
|
|
ProfesorInscrito.init(
|
|
{
|
|
idProfesorInscrito: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
unique: true,
|
|
allowNull: false,
|
|
autoIncrement: true,
|
|
},
|
|
fechaRegistro: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW,
|
|
},
|
|
},
|
|
{
|
|
sequelize,
|
|
modelName: 'ProfesorInscrito',
|
|
tableName: 'profesorInscrito',
|
|
timestamps: false,
|
|
}
|
|
);
|
|
|
|
// Relación (Sequelize crea automáticamente idProfesor con FK)
|
|
ProfesorInscrito.belongsTo(Profesor, {
|
|
foreignKey: {
|
|
name: 'idProfesor',
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
},
|
|
});
|
|
|
|
|
|
module.exports = ProfesorInscrito;
|
|
|
|
|