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

module.exports = (sequelize, DataTypes) => {
	const PostTags = sequelize.define(
		'PostTags',
		{
			id: {
				type: UUID,
				defaultValue: UUIDV4,
				primaryKey: true,
				allowNull: false,
			},
			post_id: {
				type: UUID,
				allowNull: false,
			},
			member_id: {
				type: UUID,
				allowNull: false,
			},
			status: {
				type: ENUM('Pending', 'Accepted', 'Rejected'),
				defaultValue: 'Pending',
			},
		},
		{
			tableName: 'post_tags',
			timestamps: false,
		},
	);

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

	return PostTags;
};
