시드 생성
This commit is contained in:
@@ -3,12 +3,12 @@ const { sequelize } = require('../config/database');
|
||||
|
||||
const EventScore = sequelize.define('EventScore', {
|
||||
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,7 +16,7 @@ const EventScore = sequelize.define('EventScore', {
|
||||
}
|
||||
},
|
||||
participantId: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'EventParticipants',
|
||||
@@ -24,11 +24,11 @@ const EventScore = sequelize.define('EventScore', {
|
||||
}
|
||||
},
|
||||
teamNumber: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: true,
|
||||
},
|
||||
gameNumber: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false
|
||||
},
|
||||
score: {
|
||||
@@ -49,4 +49,13 @@ const EventScore = sequelize.define('EventScore', {
|
||||
timestamps: true
|
||||
});
|
||||
|
||||
EventScore.associate = (models) => {
|
||||
EventScore.belongsTo(models.Event, {
|
||||
foreignKey: 'eventId'
|
||||
});
|
||||
EventScore.belongsTo(models.EventParticipant, {
|
||||
foreignKey: 'participantId'
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = EventScore;
|
||||
|
||||
Reference in New Issue
Block a user