bullpen/backend/migrations/09-create-player.js

56 lines
1.6 KiB
JavaScript

/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('Players', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
userId: {
type: Sequelize.INTEGER,
references: {
model: 'Users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
height: {
type: Sequelize.INTEGER
},
weight: {
type: Sequelize.INTEGER
},
gender: {
allowNull: false,
type: Sequelize.ENUM('male', 'female', 'other'),
},
bats: {
type: Sequelize.ENUM('left', 'right', 'both'),
},
throws: {
type: Sequelize.ENUM('left', 'right', 'both'),
},
jerseyNumber: {
type: Sequelize.INTEGER,
},
state: {
type: Sequelize.ENUM('active', 'injured', 'inactive'),
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
async down(queryInterface, /*Sequelize*/) {
await queryInterface.dropTable('Players');
}
};