'use strict'; module.exports = function (sequelize, DataTypes) { const EventReservation = sequelize.define('EventReservation', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, init_avalible_date: { type: DataTypes.DATE, }, end_avalible_date: { type: DataTypes.DATE, }, gmt: { type: DataTypes.INTEGER, defaultValue: 1, }, state: { type: DataTypes.STRING, allowNull: false, defaultValue: 'borrador' }, assistants: { type: DataTypes.INTEGER, }, confirmed: { type: DataTypes.INTEGER, }, allow_multiple: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, }, multiple_limit: { type: DataTypes.INTEGER, }, description: { type: DataTypes.STRING, }, code: { type: DataTypes.STRING, allowNull: false, }, color: { type: DataTypes.STRING, allowNull: false, }, allow_overflow: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, }, overflow_event_reservationId: { type: DataTypes.UUID, foreignKey: true, }, marketingList: { type: DataTypes.STRING, }, }, { tableName: 'events_reservations', freezeTableName: true, timestamps: true, }); EventReservation.associate = function (models) { EventReservation.OverflowEventReservation = EventReservation.belongsTo(models.EventReservation, { as: 'EventToEvent', foreignKey: 'overflow_event_reservationId' }); EventReservation.Entity = EventReservation.belongsTo(models.Entity, { foreignKey: 'entityId' }); EventReservation.Event = EventReservation.belongsTo(models.Event, { foreignKey: 'eventId' }); EventReservation.UserCreate = EventReservation.belongsTo(models.User, { foreignKey: 'userId' }); }; return EventReservation; };