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.
55 lines
1.3 KiB
55 lines
1.3 KiB
2 months ago
|
"use strict";
|
||
2 months ago
|
|
||
|
module.exports = {
|
||
|
up: async (queryInterface, Sequelize) => {
|
||
2 months ago
|
const tableExists = await queryInterface
|
||
|
.describeTable("Invoices")
|
||
|
.then(() => true)
|
||
|
.catch(() => false);
|
||
|
|
||
|
if (tableExists) {
|
||
|
await queryInterface.dropTable("Invoices", { cascade: true });
|
||
|
}
|
||
|
await queryInterface.createTable("Invoices", {
|
||
2 months ago
|
id: {
|
||
|
type: Sequelize.INTEGER,
|
||
|
autoIncrement: true,
|
||
|
primaryKey: true,
|
||
2 months ago
|
allowNull: false,
|
||
2 months ago
|
},
|
||
|
userId: {
|
||
|
type: Sequelize.INTEGER,
|
||
|
allowNull: false,
|
||
|
references: {
|
||
2 months ago
|
model: "Users",
|
||
|
key: "id",
|
||
2 months ago
|
},
|
||
2 months ago
|
onDelete: "CASCADE",
|
||
2 months ago
|
},
|
||
2 months ago
|
totalPaymentAmount: {
|
||
|
type: Sequelize.FLOAT,
|
||
2 months ago
|
allowNull: false,
|
||
|
},
|
||
2 months ago
|
status: {
|
||
|
type: Sequelize.ENUM("pending", "paid"),
|
||
|
allowNull: false,
|
||
|
defaultValue: "pending",
|
||
|
},
|
||
2 months ago
|
createdAt: {
|
||
|
type: Sequelize.DATE,
|
||
|
allowNull: false,
|
||
2 months ago
|
defaultValue: Sequelize.fn("NOW"),
|
||
2 months ago
|
},
|
||
|
updatedAt: {
|
||
|
type: Sequelize.DATE,
|
||
|
allowNull: false,
|
||
2 months ago
|
defaultValue: Sequelize.fn("NOW"),
|
||
2 months ago
|
},
|
||
|
});
|
||
|
},
|
||
|
|
||
|
down: async (queryInterface, Sequelize) => {
|
||
2 months ago
|
await queryInterface.dropTable("Invoices", { cascade: true });
|
||
2 months ago
|
},
|
||
|
};
|