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.
54 lines
1.3 KiB
54 lines
1.3 KiB
"use strict"; |
|
|
|
module.exports = { |
|
up: async (queryInterface, Sequelize) => { |
|
const tableExists = await queryInterface |
|
.describeTable("Invoices") |
|
.then(() => true) |
|
.catch(() => false); |
|
|
|
if (tableExists) { |
|
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", |
|
}, |
|
totalPaymentAmount: { |
|
type: Sequelize.FLOAT, |
|
allowNull: false, |
|
}, |
|
status: { |
|
type: Sequelize.ENUM("pending", "paid"), |
|
allowNull: false, |
|
defaultValue: "pending", |
|
}, |
|
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", { cascade: true }); |
|
}, |
|
};
|
|
|