시드 생성

This commit is contained in:
2025-04-24 12:01:51 +09:00
parent beac42d60c
commit 7fa99e6988
42 changed files with 938 additions and 1170 deletions
+22 -2
View File
@@ -3,7 +3,7 @@ const { sequelize } = require('../config/database');
const Club = sequelize.define('Club', {
id: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
@@ -16,7 +16,7 @@ const Club = sequelize.define('Club', {
allowNull: true
},
ownerId: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Users',
@@ -54,4 +54,24 @@ const Club = sequelize.define('Club', {
timestamps: true
});
Club.associate = (models) => {
Club.hasMany(models.ClubFeature, { foreignKey: 'clubId' });
Club.hasMany(models.ClubSubscription, { foreignKey: 'clubId' });
Club.belongsTo(models.User, { foreignKey: 'ownerId', as: 'owner' });
Club.belongsToMany(models.Feature, {
through: models.ClubFeature,
foreignKey: 'clubId',
});
Club.belongsToMany(models.SubscriptionPlan, {
through: models.ClubSubscription,
foreignKey: 'clubId',
otherKey: 'planId',
});
Club.hasMany(models.ClubSubscription, { foreignKey: 'clubId' });
Club.belongsToMany(models.Feature, {
through: models.ClubFeature,
foreignKey: 'clubId',
});
};
module.exports = Club;