diff --git a/migrations/20250104074851-create-user.js b/migrations/20250104074851-create-user.js index 912f654..f88aca3 100644 --- a/migrations/20250104074851-create-user.js +++ b/migrations/20250104074851-create-user.js @@ -3,6 +3,7 @@ /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { + await queryInterface.dropTable('Users',{cascade:true}) await queryInterface.createTable('Users', { id: { allowNull: false, diff --git a/migrations/20250104094702-create-admin.js b/migrations/20250104094702-create-admin.js index 77c56a4..e48a8a4 100644 --- a/migrations/20250104094702-create-admin.js +++ b/migrations/20250104094702-create-admin.js @@ -2,6 +2,8 @@ module.exports = { up: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('Admins', { cascade: true }); + await queryInterface.createTable('Admins', { id: { allowNull: false, diff --git a/migrations/20250104112403-create-product.js b/migrations/20250104112403-create-product.js index 7aa182e..b707233 100644 --- a/migrations/20250104112403-create-product.js +++ b/migrations/20250104112403-create-product.js @@ -1,8 +1,10 @@ -'use strict'; +"use strict"; module.exports = { up: async (queryInterface, Sequelize) => { - await queryInterface.createTable('Products', { + await queryInterface.dropTable("Products", { cascade: true }); + + await queryInterface.createTable("Products", { id: { type: Sequelize.INTEGER, allowNull: false, @@ -60,6 +62,6 @@ module.exports = { }, down: async (queryInterface, Sequelize) => { - await queryInterface.dropTable('Products'); + await queryInterface.dropTable("Products"); }, }; diff --git a/migrations/20250105063054-create-cart.js b/migrations/20250105063054-create-cart.js index 2b84cb7..2dfc15d 100644 --- a/migrations/20250105063054-create-cart.js +++ b/migrations/20250105063054-create-cart.js @@ -2,6 +2,8 @@ module.exports = { up: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('Carts', { cascade: true }); + await queryInterface.createTable('Carts', { id: { type: Sequelize.INTEGER, diff --git a/migrations/20250105085732-create-invoice.js b/migrations/20250105085732-create-invoice.js index 2cf1a2f..af7f78d 100644 --- a/migrations/20250105085732-create-invoice.js +++ b/migrations/20250105085732-create-invoice.js @@ -2,52 +2,76 @@ module.exports = { up: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('Invoices', { cascade: true }); + await queryInterface.createTable('Invoices', { id: { type: Sequelize.INTEGER, - allowNull: false, autoIncrement: true, primaryKey: true, + allowNull: false, }, userId: { type: Sequelize.INTEGER, allowNull: false, references: { - model: 'Users', - key: 'id', + model: 'Users', + key: 'id', }, - onDelete: 'CASCADE', + onDelete: 'CASCADE', + }, + firstName: { + type: Sequelize.STRING, + allowNull: false, + }, + lastName: { + type: Sequelize.STRING, + allowNull: false, + }, + phoneNumber: { + type: Sequelize.STRING, + allowNull: false, + }, + email: { + type: Sequelize.STRING, + allowNull: false, + unique: false, }, totalAmount: { + type: Sequelize.FLOAT, + allowNull: true, + }, + productId: { type: Sequelize.INTEGER, allowNull: false, }, - products: { - type: Sequelize.JSON, + quantity: { + type: Sequelize.INTEGER, allowNull: false, }, - paymentStatus: { - type: Sequelize.STRING, + price: { + type: Sequelize.DECIMAL(10, 2), allowNull: false, }, - refId: { + productName: { type: Sequelize.STRING, allowNull: false, }, createdAt: { type: Sequelize.DATE, allowNull: false, - defaultValue: Sequelize.NOW, + defaultValue: Sequelize.fn('NOW'), }, updatedAt: { type: Sequelize.DATE, allowNull: false, - defaultValue: Sequelize.NOW, + defaultValue: Sequelize.fn('NOW'), }, }); }, down: async (queryInterface, Sequelize) => { + await queryInterface.dropTable('Invoices'); }, };