시드 생성
This commit is contained in:
@@ -3,7 +3,7 @@ const { sequelize } = require('../config/database');
|
||||
|
||||
const SubscriptionPlan = sequelize.define('SubscriptionPlan', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
@@ -33,4 +33,20 @@ const SubscriptionPlan = sequelize.define('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;
|
||||
|
||||
Reference in New Issue
Block a user