20260228063014-bookings.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. /** @type {import('sequelize-cli').Migration} */
  3. module.exports = {
  4. async up (queryInterface, Sequelize) {
  5. await queryInterface.createTable('bookings', {
  6. booking_id: {
  7. allowNull: false,
  8. autoIncrement: true,
  9. primaryKey: true,
  10. type: Sequelize.DataTypes.INTEGER
  11. },
  12. client_id: {
  13. type: Sequelize.DataTypes.INTEGER,
  14. allowNull: false,
  15. references: {
  16. model: 'clients',
  17. key: 'client_id'
  18. },
  19. onDelete: 'RESTRICT',
  20. onUpdate: 'CASCADE',
  21. comment: 'ID клиента'
  22. },
  23. hall_id: {
  24. type: Sequelize.DataTypes.INTEGER,
  25. allowNull: false,
  26. references: {
  27. model: 'halls',
  28. key: 'hall_id'
  29. },
  30. onDelete: 'RESTRICT',
  31. onUpdate: 'CASCADE',
  32. comment: 'ID зала'
  33. },
  34. photographer_id: {
  35. type: Sequelize.DataTypes.INTEGER,
  36. allowNull: true,
  37. references: {
  38. model: 'photographers',
  39. key: 'photographer_id'
  40. },
  41. onDelete: 'SET NULL',
  42. onUpdate: 'CASCADE',
  43. comment: 'ID фотографа'
  44. },
  45. start_time: {
  46. type: Sequelize.DataTypes.DATE,
  47. allowNull: false,
  48. comment: 'Время начала'
  49. },
  50. end_time: {
  51. type: Sequelize.DataTypes.DATE,
  52. allowNull: false,
  53. comment: 'Время окончания'
  54. },
  55. total_cost: {
  56. type: Sequelize.DataTypes.DECIMAL(10, 2),
  57. allowNull: true,
  58. comment: 'Общая стоимость'
  59. },
  60. status: {
  61. type: Sequelize.DataTypes.ENUM('pending', 'confirmed', 'completed', 'cancelled'),
  62. allowNull: true,
  63. defaultValue: 'pending',
  64. comment: 'Статус бронирования'
  65. },
  66. created_at: {
  67. type: Sequelize.DataTypes.DATE,
  68. allowNull: true,
  69. defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
  70. comment: 'Дата создания'
  71. }
  72. })
  73. },
  74. async down (queryInterface, Sequelize) {
  75. await queryInterface.dropTable('bookings')
  76. }
  77. }