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

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

	RestaurantReviewImages.associate = (models) => {
		RestaurantReviewImages.belongsTo(models.RestaurantReviews, {
			foreignKey: 'restaurant_review_id',
			as: 'review',
		});
	};

	return RestaurantReviewImages;
};
