20260228062956-booking_services.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. /** @type {import('sequelize-cli').Migration} */
  3. module.exports = {
  4. async up (queryInterface, Sequelize) {
  5. await queryInterface.createTable('booking_services', {
  6. booking_id: {
  7. type: Sequelize.DataTypes.INTEGER,
  8. allowNull: false,
  9. primaryKey: true,
  10. references: {
  11. model: 'bookings',
  12. key: 'booking_id'
  13. },
  14. onDelete: 'CASCADE',
  15. onUpdate: 'CASCADE'
  16. },
  17. service_id: {
  18. type: Sequelize.DataTypes.INTEGER,
  19. allowNull: false,
  20. primaryKey: true,
  21. references: {
  22. model: 'services',
  23. key: 'service_id'
  24. },
  25. onDelete: 'RESTRICT',
  26. onUpdate: 'CASCADE'
  27. },
  28. quantity: {
  29. type: Sequelize.DataTypes.INTEGER,
  30. allowNull: true,
  31. defaultValue: 1,
  32. comment: 'Количество'
  33. },
  34. price_at_booking: {
  35. type: Sequelize.DataTypes.DECIMAL(10, 2),
  36. allowNull: true,
  37. comment: 'Цена на момент бронирования'
  38. }
  39. })
  40. },
  41. async down (queryInterface, Sequelize) {
  42. await queryInterface.dropTable('booking_services')
  43. }
  44. }