| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- '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')
- }
- }
|