const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const SubscriptionPlan = sequelize.define('SubscriptionPlan', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true }, name: { type: DataTypes.STRING, allowNull: false }, description: { type: DataTypes.TEXT }, maxMembers: { type: DataTypes.INTEGER, allowNull: false }, price: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 }, status: { type: DataTypes.ENUM('active', 'inactive'), defaultValue: 'active', allowNull: false } }, { tableName: 'SubscriptionPlan', timestamps: true }); SubscriptionPlan.associate = (models) => { SubscriptionPlan.belongsToMany(models.Club, { through: models.ClubSubscription, foreignKey: 'planId', otherKey: 'clubId', }); SubscriptionPlan.belongsToMany(models.Feature, { through: models.SubscriptionPlanFeature, foreignKey: 'planId', otherKey: 'featureId', }); SubscriptionPlan.hasMany(models.ClubSubscription, { foreignKey: 'planId', }); }; module.exports = SubscriptionPlan;