ready to test

Testing

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-06-22 10:06:58 +08:00
parent bf48c95467
commit 439bb33f77
189 changed files with 17559 additions and 686 deletions
@@ -0,0 +1,29 @@
'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('course_purchases', {
id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
product_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'products', key: 'id' }, onDelete: 'RESTRICT' },
amount: { type: Sequelize.DECIMAL(10, 2), allowNull: false },
currency: { type: Sequelize.STRING(10), allowNull: false, defaultValue: 'USD' },
status: { type: Sequelize.ENUM('pending', 'completed', 'failed', 'cancelled', 'refunded'), allowNull: false, defaultValue: 'pending' },
provider: { type: Sequelize.STRING(50), allowNull: false, defaultValue: 'paypal' },
provider_payload: { type: Sequelize.JSONB, allowNull: true, defaultValue: {} },
expires_at: { type: Sequelize.DATE, allowNull: true }, // null = lifetime access
paid_at: { type: Sequelize.DATE, allowNull: true },
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false },
deletedAt: { type: Sequelize.DATE, allowNull: true },
});
await queryInterface.addIndex('course_purchases', ['user_id']);
await queryInterface.addIndex('course_purchases', ['product_id']);
await queryInterface.addIndex('course_purchases', ['status']);
},
async down(queryInterface) {
await queryInterface.dropTable('course_purchases');
},
};