updated db migration

This commit is contained in:
2026-07-20 12:28:46 +08:00
parent a2c9936f79
commit d665897ef5
129 changed files with 574 additions and 1878 deletions
@@ -0,0 +1,30 @@
'use strict';
// `tier` started as ENUM('premium','exclusive') but 20260101000063 dropped
// its CHECK constraint entirely so it can hold any tier_categories.slug
// value (including admin-created ones) — it's a free-form STRING now, not
// an enum.
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('tier_plans', {
plan_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
tier: { type: Sequelize.STRING(20), allowNull: false },
label: { type: Sequelize.STRING(100), allowNull: false },
description: { type: Sequelize.TEXT, allowNull: true },
features: { type: Sequelize.JSONB, allowNull: true },
duration_days: { type: Sequelize.FLOAT, allowNull: false },
duration_unit: { type: Sequelize.STRING(10), allowNull: false, defaultValue: 'day' },
price: { type: Sequelize.DECIMAL(10, 2), allowNull: false },
currency: { type: Sequelize.CHAR(3), allowNull: false, defaultValue: 'USD' },
is_active: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true },
tier_category_id: { type: Sequelize.BIGINT, allowNull: true, references: { model: 'tier_categories', key: 'tier_category_id' }, onUpdate: 'CASCADE', onDelete: 'SET NULL' },
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false },
deletedAt: { type: Sequelize.DATE, allowNull: true },
});
},
async down(queryInterface) {
await queryInterface.dropTable('tier_plans');
},
};