You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

'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: true,
references: {
model: 'Products',
key: 'id',
},
onDelete: 'CASCADE',
},
invoiceId: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'Invoices',
key: 'id',
},
onDelete: 'CASCADE',
},
quantity: {
type: Sequelize.INTEGER,
allowNull: true,
},
productPrice: {
type: Sequelize.DECIMAL(10, 2),
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');
},
};