const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const SubscriptionPlan = sequelize.define('SubscriptionPlan', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '구독 플랜 고유 식별자' }, name: { type: DataTypes.STRING, allowNull: false, comment: '플랜명' }, description: { type: DataTypes.TEXT, comment: '플랜 설명' }, maxMembers: { type: DataTypes.INTEGER, allowNull: false, comment: '최대 허용 회원 수' }, price: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, comment: '플랜 가격' }, status: { type: DataTypes.ENUM('active', 'inactive'), defaultValue: 'active', allowNull: false, comment: '플랜 상태' } }, { tableName: 'SubscriptionPlan', comment: '구독 플랜 정보를 저장하는 테이블', 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;