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.
80 lines
1.8 KiB
80 lines
1.8 KiB
"use strict"; |
|
|
|
module.exports = { |
|
up: async (queryInterface, Sequelize) => { |
|
await queryInterface.dropTable("Invoices", { cascade: true }); |
|
|
|
await queryInterface.createTable("Invoices", { |
|
id: { |
|
type: Sequelize.INTEGER, |
|
autoIncrement: true, |
|
primaryKey: true, |
|
allowNull: false, |
|
}, |
|
userId: { |
|
type: Sequelize.INTEGER, |
|
allowNull: false, |
|
references: { |
|
model: "Users", |
|
key: "id", |
|
}, |
|
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, |
|
}, |
|
totalPaymentAmount: { |
|
type: Sequelize.DECIMAL(10, 2), |
|
allowNull: true, |
|
}, |
|
productId: { |
|
type: Sequelize.INTEGER, |
|
allowNull: false, |
|
}, |
|
quantity: { |
|
type: Sequelize.INTEGER, |
|
allowNull: false, |
|
}, |
|
price: { |
|
type: Sequelize.DECIMAL(10, 2), |
|
allowNull: false, |
|
}, |
|
totalPrice: { |
|
type: Sequelize.DECIMAL(10, 2), |
|
allowNull: false, |
|
}, |
|
productName: { |
|
type: Sequelize.STRING, |
|
allowNull: false, |
|
}, |
|
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("Invoices"); |
|
}, |
|
};
|
|
|