const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
	const HotelImages = sequelize.define(
		'HotelImages',
		{
			id: {
				type: DataTypes.UUID,
				defaultValue: DataTypes.UUIDV4,
				primaryKey: true,
				allowNull: false,
			},
			hotel_id: {
				type: DataTypes.UUID,
				allowNull: false,
				references: {
					model: 'hotels',
					key: 'id',
				},
			},
			image: {
				type: DataTypes.STRING,
				allowNull: false,
			},
		},
		{
			tableName: 'hotel_images',
			timestamps: false,
		},
	);

	HotelImages.associate = (models) => {
		HotelImages.belongsTo(models.Hotels, {
			foreignKey: 'hotel_id',
			as: 'hotel',
		});
	};

	return HotelImages;
};
