'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.dropTable("Carts", { cascade: true }); await queryInterface.createTable('Carts', { id: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true, allowNull: false, }, userId: { type: Sequelize.INTEGER, allowNull: false, references: { model: 'Users', key: 'id', }, onDelete: 'CASCADE', }, productId: { type: Sequelize.INTEGER, allowNull: false, references: { model: 'Products', key: 'id', }, onDelete: 'CASCADE', }, invoiceId: { type: Sequelize.INTEGER, allowNull: false, references: { model: 'Invoices', // نام جدول Invoices key: 'id', }, onDelete: 'CASCADE', }, quantity: { type: Sequelize.INTEGER, allowNull: true, }, productPrice: { type: Sequelize.INTEGER, allowNull: true, }, status: { type: Sequelize.ENUM('open', 'closed'), allowNull: false, defaultValue: 'open', }, createdAt: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.fn('NOW'), }, updatedAt: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.fn('NOW'), }, }); }, down: async (queryInterface, Sequelize) => { await queryInterface.dropTable('Carts'); }, };