mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
revised: payment strategy
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
// Backstop for the stacked-tier model: application code now enforces "at most
|
||||
// one active row per (user_id, tier)" (see controllers/client/tiers.controller.js
|
||||
// createOrder/captureOrder and controllers/admin/tiers.controller.js grantTier),
|
||||
// but a race or a future code path could still violate it. This partial unique
|
||||
// index makes the DB reject that case outright instead of silently allowing two
|
||||
// active rows for the same user+tier.
|
||||
//
|
||||
// NOT auto-run — this file only defines the migration. Do not execute it against
|
||||
// the shared dev/prod database without explicit confirmation.
|
||||
module.exports = {
|
||||
async up(queryInterface) {
|
||||
await queryInterface.addIndex('user_tiers', ['user_id', 'tier'], {
|
||||
unique: true,
|
||||
where: { status: 'active' },
|
||||
name: 'user_tiers_one_active_per_user_tier',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeIndex('user_tiers', 'user_tiers_one_active_per_user_tier');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user