'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    await queryInterface.createTable('booking_services', {
      booking_id: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        references: {
          model: 'bookings',
          key: 'booking_id'
        },
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE'
      },
      service_id: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        references: {
          model: 'services',
          key: 'service_id'
        },
        onDelete: 'RESTRICT',
        onUpdate: 'CASCADE'
      },
      quantity: {
        type: Sequelize.DataTypes.INTEGER,
        allowNull: true,
        defaultValue: 1,
        comment: 'Количество'
      },
      price_at_booking: {
        type: Sequelize.DataTypes.DECIMAL(10, 2),
        allowNull: true,
        comment: 'Цена на момент бронирования'
      }
    })
  },
  async down (queryInterface, Sequelize) {
    await queryInterface.dropTable('booking_services')
  }
}