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

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

	HotelReviewImages.associate = (models) => {
		HotelReviewImages.belongsTo(models.HotelReviews, {
			foreignKey: 'hotel_review_id',
			as: 'review',
		});
	};

	return HotelReviewImages;
};
