mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
29 lines
969 B
JavaScript
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');
|
|
},
|
|
};
|