Files
starr-philproperties/database/migrations/20260101000038-add-fks-to-course-junction-tables.js
T
kennethobsequio 439bb33f77 ready to test
Testing

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-06-22 10:06:58 +08:00

29 lines
969 B
JavaScript

'use strict';
// Wires up the bare product_id and category_id columns that were left
// as plain integers in migration 000008.
module.exports = {
async up(queryInterface) {
await queryInterface.addConstraint('course_products', {
fields: ['product_id'],
type: 'foreign key',
name: 'fk_course_products_product_id',
references: { table: 'products', field: 'id' },
onDelete: 'CASCADE',
});
await queryInterface.addConstraint('course_product_categories', {
fields: ['category_id'],
type: 'foreign key',
name: 'fk_course_product_categories_category_id',
references: { table: 'categories', field: 'id' },
onDelete: 'CASCADE',
});
},
async down(queryInterface) {
await queryInterface.removeConstraint('course_products', 'fk_course_products_product_id');
await queryInterface.removeConstraint('course_product_categories', 'fk_course_product_categories_category_id');
},
};