Files
bowlingManager/backend/models/SubscriptionPlan.js
T
2025-04-24 12:01:51 +09:00

53 lines
1.1 KiB
JavaScript

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;