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

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

	HotelRoomImages.associate = (models) => {
		HotelRoomImages.belongsTo(models.HotelRooms, {
			foreignKey: 'hotel_room_id',
			as: 'room',
		});
	};

	return HotelRoomImages;
};
