mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('tier_plans', 'description', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
after: 'label',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn('tier_plans', 'description');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('payment_policies', {
|
||||
policy_id: {
|
||||
type: Sequelize.BIGINT,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
plan_id: {
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: true,
|
||||
unique: true,
|
||||
references: { model: 'tier_plans', key: 'plan_id' },
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
// Array of { code, type:'flat'|'percent', value, currency?, max_discount?,
|
||||
// max_uses?, expires_at?, min_amount? }
|
||||
promo_rules: {
|
||||
type: Sequelize.JSONB,
|
||||
allowNull: false,
|
||||
defaultValue: [],
|
||||
},
|
||||
// { allowed, window_value, window_unit:'minutes'|'hours'|'days', reason_required }
|
||||
refund_policy: {
|
||||
type: Sequelize.JSONB,
|
||||
allowNull: false,
|
||||
defaultValue: { allowed: true, window_value: 5, window_unit: 'minutes', reason_required: false },
|
||||
},
|
||||
// e.g. ["paypal"]
|
||||
allowed_providers: {
|
||||
type: Sequelize.JSONB,
|
||||
allowNull: false,
|
||||
defaultValue: ['paypal'],
|
||||
},
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('payment_policies', ['plan_id']);
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('payment_policies');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('tier_plans', 'duration_unit', {
|
||||
type: Sequelize.STRING(10),
|
||||
allowNull: false,
|
||||
defaultValue: 'day',
|
||||
});
|
||||
await queryInterface.changeColumn('tier_plans', 'duration_days', {
|
||||
type: Sequelize.FLOAT,
|
||||
allowNull: false,
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.removeColumn('tier_plans', 'duration_unit');
|
||||
await queryInterface.changeColumn('tier_plans', 'duration_days', {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('users', 'preferred_currency', {
|
||||
type: Sequelize.CHAR(3),
|
||||
allowNull: false,
|
||||
defaultValue: 'USD',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn('users', 'preferred_currency');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('plan_prices', {
|
||||
price_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
plan_id: {
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: false,
|
||||
references: { model: 'tier_plans', key: 'plan_id' },
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
currency: { type: Sequelize.CHAR(3), allowNull: false },
|
||||
price: { type: Sequelize.DECIMAL(10, 2), allowNull: false },
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addConstraint('plan_prices', {
|
||||
fields: ['plan_id', 'currency'],
|
||||
type: 'unique',
|
||||
name: 'uq_plan_prices_plan_currency',
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('plan_prices', ['plan_id'], {
|
||||
name: 'idx_plan_prices_plan_id',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('plan_prices');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('course_achievements', {
|
||||
id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
course_id: { type: Sequelize.BIGINT, allowNull: false },
|
||||
achievement_key: { type: Sequelize.STRING(100), allowNull: false },
|
||||
order_index: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('course_achievements', ['course_id']);
|
||||
await queryInterface.addConstraint('course_achievements', {
|
||||
fields: ['course_id', 'achievement_key'],
|
||||
type: 'unique',
|
||||
name: 'course_achievements_course_id_key_unique',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('course_achievements');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user