module.exports = (sequelize, DataTypes) => {
	const EventAttendies = sequelize.define(
		'EventAttendies',
		{
			id: {
				type: DataTypes.UUID,
				defaultValue: DataTypes.UUIDV4,
				primaryKey: true,
				allowNull: false,
			},
			event_id: {
				type: DataTypes.UUID,
				allowNull: true,
			},
			member_id: {
				type: DataTypes.UUID,
				allowNull: false,
			},
			convention_user_id: {
				type: DataTypes.UUID,
				allowNull: false,
			},
			ticket_id: {
				type: DataTypes.UUID,
				allowNull: false,
			},
			food_stab: {
				type: DataTypes.ENUM('Claimed', 'Not Claimed'),
				allowNull: true,
			},
			convention_center: {
				type: DataTypes.STRING,
				allowNull: true,
			},
			timestamp: {
				type: DataTypes.DATE,
				allowNull: true,
			},
			scanned_by: {
				type: DataTypes.STRING,
				allowNull: true,
			},
			worldcon_ticket_id: {
				type: DataTypes.UUID,
				allowNull: true,
			},
		},
		{
			tableName: 'event_attendies',
			timestamps: true,
		},
	);

	EventAttendies.associate = (models) => {
		EventAttendies.belongsTo(models.Events, {
			foreignKey: 'event_id',
			as: 'event',
		});
		EventAttendies.belongsTo(models.Members, {
			foreignKey: 'member_id',
			as: 'member',
		});
		EventAttendies.belongsTo(models.ConventionUsers, {
			foreignKey: 'convention_user_id',
			as: 'convention',
		});
		EventAttendies.belongsTo(models.Tickets, {
			foreignKey: 'ticket_id',
			as: 'ticket',
		});
	};

	return EventAttendies;
};
