mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
ready to test
Testing Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user