'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    await queryInterface.createTable('booking_equipment', {
      booking_id: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        references: {
          model: 'bookings',
          key: 'booking_id'
        },
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE'
      },
      equipment_id: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        references: {
          model: 'equipment',
          key: 'equipment_id'
        },
        onDelete: 'RESTRICT',
        onUpdate: 'CASCADE'
      },
      quantity: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: true,
        defaultValue: 1,
        comment: 'Количество'
      }
    })
  },
  async down (queryInterface, Sequelize) {
    await queryInterface.dropTable('booking_equipment')
  }
}