002-brands.js 661 B

123456789101112131415161718192021
  1. "use strict";
  2. const faker = require("faker");
  3. const { generateUniqueList } = require("../seedersUtils");
  4. const { seedValue, seedRowCounts } = require("../src/config/seeders");
  5. const TABLE_NAME = "sl_brands";
  6. module.exports = {
  7. up: async (queryInterface, Sequelize) => {
  8. faker.seed(seedValue);
  9. const uniqueNames = generateUniqueList(seedRowCounts.brands, () => faker.company.companyName());
  10. const data = uniqueNames.map((name, index) => ({ id: index + 1, name }));
  11. await queryInterface.bulkInsert(TABLE_NAME, data, {});
  12. },
  13. down: async (queryInterface, Sequelize) => {
  14. await queryInterface.bulkDelete(TABLE_NAME, null, {});
  15. },
  16. };