시드 생성

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
+24 -9
View File
@@ -3,12 +3,12 @@ const { sequelize } = require('../config/database');
const EventParticipant = sequelize.define('EventParticipant', {
id: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
primaryKey: true,
autoIncrement: true
},
eventId: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Events',
@@ -16,13 +16,21 @@ const EventParticipant = sequelize.define('EventParticipant', {
}
},
memberId: {
type: DataTypes.INTEGER,
type: DataTypes.INTEGER.UNSIGNED,
allowNull: false,
references: {
model: 'Members',
key: 'id'
}
},
teamId: {
type: DataTypes.INTEGER.UNSIGNED,
allowNull: true,
references: {
model: 'EventTeams',
key: 'id'
}
},
status: {
type: DataTypes.ENUM('참가예정', '참가확정', '취소'),
allowNull: false,
@@ -41,18 +49,25 @@ const EventParticipant = sequelize.define('EventParticipant', {
// 관계 설정
EventParticipant.associate = (models) => {
EventParticipant.belongsTo(models.Event, {
foreignKey: 'eventId',
as: 'event'
foreignKey: 'eventId'
});
EventParticipant.belongsTo(models.Member, {
foreignKey: 'memberId',
as: 'member'
foreignKey: 'memberId'
});
EventParticipant.belongsTo(models.EventTeam, {
foreignKey: 'teamId'
});
EventParticipant.hasMany(models.EventScore, {
foreignKey: 'participantId',
as: 'scores'
foreignKey: 'participantId'
});
};
EventParticipant.associate = (models) => {
EventParticipant.hasMany(models.EventScore, {
foreignKey: 'participantId'
});
};