시드 생성

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
+17 -8
View File
@@ -3,12 +3,12 @@ const { sequelize } = require('../config/database');
const Event = sequelize.define('Event', {
id: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
clubId: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Clubs',
@@ -85,18 +85,27 @@ const Event = sequelize.define('Event', {
// 관계 설정
Event.associate = (models) => {
Event.belongsTo(models.Club, {
foreignKey: 'clubId',
as: 'club'
foreignKey: 'clubId'
});
Event.hasMany(models.EventParticipant, {
foreignKey: 'eventId',
as: 'participants'
foreignKey: 'eventId'
});
Event.hasMany(models.EventScore, {
foreignKey: 'eventId',
as: 'scores'
foreignKey: 'eventId'
});
};
Event.associate = (models) => {
Event.belongsTo(models.Club, {
foreignKey: 'clubId'
});
Event.hasMany(models.EventParticipant, {
foreignKey: 'eventId'
});
Event.hasMany(models.EventScore, {
foreignKey: 'eventId'
});
};