20250225034424-article.js 741 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. /** @type {import('sequelize-cli').Migration} */
  3. module.exports = {
  4. async up (queryInterface, Sequelize) {
  5. const articles = [];
  6. const counts = 10;
  7. for(let i = 1; i<= counts;i++){
  8. const article = {
  9. title:`文章的标题${i}`,
  10. content:`文章的内容${i}`,
  11. author:`文章的作者${i}`,
  12. category:`文章的分类${i}`,
  13. crop:`文章的作物${i}`,
  14. img:`文章的图片${i}`,
  15. createdAt:new Date(),
  16. updatedAt:new Date()
  17. }
  18. articles.push(article)
  19. }
  20. await queryInterface.bulkInsert('Articles',articles,{})
  21. },
  22. async down (queryInterface, Sequelize) {
  23. await queryInterface.bulkDelete('Articles', null, {});
  24. }
  25. };