@@ -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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user