20260312072303-favorites.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. /** @type {import('sequelize-cli').Migration} */
  3. module.exports = {
  4. async up (queryInterface, Sequelize) {
  5. await queryInterface.createTable('favorites', {
  6. favorite_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: 'CASCADE',
  20. onUpdate: 'CASCADE'
  21. },
  22. hall_id: {
  23. type: Sequelize.DataTypes.INTEGER,
  24. allowNull: true,
  25. references: {
  26. model: 'halls',
  27. key: 'hall_id'
  28. },
  29. onDelete: 'CASCADE'
  30. },
  31. photographer_id: {
  32. type: Sequelize.DataTypes.INTEGER,
  33. allowNull: true,
  34. references: {
  35. model: 'photographers',
  36. key: 'photographer_id'
  37. },
  38. onDelete: 'CASCADE'
  39. }
  40. });
  41. },
  42. async down (queryInterface, Sequelize) {
  43. await queryInterface.dropTable('favorites');
  44. }
  45. };