const { UUID, UUIDV4 } = require('sequelize');

module.exports = (sequelize, DataTypes) => {
	const PostLikes = sequelize.define(
		'PostLikes',
		{
			id: {
				type: UUID,
				defaultValue: UUIDV4,
				primaryKey: true,
				allowNull: false,
			},
			post_id: {
				type: UUID,
				allowNull: false,
			},
			member_id: {
				type: UUID,
				allowNull: false,
			},
		},
		{
			tableName: 'post_likes',
			timestamps: false,
		},
	);

	PostLikes.associate = (models) => {
		PostLikes.belongsTo(models.Members, { as: 'member', foreignKey: 'member_id' });
	};

	return PostLikes;
};
