Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
754 B
4
Indexable
Never
// 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