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

55 lines
1.2 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const ClubSubscription = sequelize.define('ClubSubscription', {
id: {
type: DataTypes.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
clubId: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Clubs',
key: 'id'
}
},
planId: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'SubscriptionPlans',
key: 'id'
}
},
status: {
type: DataTypes.ENUM('active', 'expired', 'suspended'),
defaultValue: 'active',
allowNull: false
},
startDate: {
type: DataTypes.DATE,
allowNull: false
},
endDate: {
type: DataTypes.DATE,
allowNull: false
},
price: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0
}
}, {
tableName: 'ClubSubscriptions',
timestamps: true
});
ClubSubscription.associate = (models) => {
ClubSubscription.belongsTo(models.SubscriptionPlan, { foreignKey: 'planId' });
ClubSubscription.belongsTo(models.Club, { foreignKey: 'clubId' });
};
module.exports = ClubSubscription;