71 lines
1.5 KiB
JavaScript
71 lines
1.5 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const EventScore = sequelize.define('EventScore', {
|
|
id: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
comment: '점수 고유 식별자'
|
|
},
|
|
eventId: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'Events',
|
|
key: 'id'
|
|
},
|
|
comment: '이벤트 ID'
|
|
},
|
|
participantId: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'EventParticipants',
|
|
key: 'id'
|
|
},
|
|
comment: '이벤트 참가자 ID'
|
|
},
|
|
teamNumber: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: true,
|
|
comment: '팀 번호'
|
|
},
|
|
gameNumber: {
|
|
type: DataTypes.INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
comment: '게임 번호'
|
|
},
|
|
score: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
comment: '점수'
|
|
},
|
|
handicap: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 0,
|
|
comment: '핸디캡'
|
|
},
|
|
totalScore: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
comment: '총점'
|
|
}
|
|
}, {
|
|
tableName: 'EventScores',
|
|
comment: '이벤트별 참가자 점수 정보를 저장하는 테이블',
|
|
timestamps: true
|
|
});
|
|
|
|
EventScore.associate = (models) => {
|
|
EventScore.belongsTo(models.Event, {
|
|
foreignKey: 'eventId'
|
|
});
|
|
EventScore.belongsTo(models.EventParticipant, {
|
|
foreignKey: 'participantId'
|
|
});
|
|
};
|
|
|
|
module.exports = EventScore;
|