Untitled
// post_categories module.exports = { up: async (QueryInterface, Sequelize) => { await QueryInterface.createTable('posts_categories', { post_id: { type: Sequelize.INTEGER, primaryKey: true, references: { model: 'blog_posts', key: 'id', }, onUpdate: 'CASCADE', onDelete: 'CASCADE' }, categoryId: { field: 'category_id', type: Sequelize.INTEGER, primaryKey: true, references: { model: 'categories', key: 'id', }, onUpdate: 'CASCADE', onDelete: 'CASCADE' }, }); }, down: async (QueryInterface, _Sequelize) => { await QueryInterface.dropTable('posts_categories'); }, };
Leave a Comment