'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { 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.INTEGER, 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'), }, }); await queryInterface.addConstraint('Invoices', { fields: ['userId'], type: 'foreign key', name: 'fk_user_id', references: { table: 'Users', field: 'id', }, onDelete: 'CASCADE', }); }, down: async (queryInterface, Sequelize) => { await queryInterface.dropTable('Invoices'); }, };