003-robots.js 1023 B

1234567891011121314151617181920212223242526272829
  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_robots";
  6. module.exports = {
  7. up: async (queryInterface, Sequelize) => {
  8. faker.seed(seedValue);
  9. const uniqueNames = generateUniqueList(seedRowCounts.robots, () => faker.company.catchPhrase());
  10. const data = uniqueNames.map((name, index) => ({
  11. id: index + 1,
  12. name,
  13. type: faker.random.arrayElement(["cleaning", "kitchen", "warehouse"]),
  14. autonomy: faker.random.number({ min: 1, max: 72 }),
  15. weight: faker.random.arrayElement([1, 5, 8, 14, 25, 50]),
  16. price: faker.random.arrayElement([1, 2, 3, 5, 8, 13]) * 1000000,
  17. brandId: faker.random.number({ min: 1, max: seedRowCounts.brands }),
  18. }));
  19. await queryInterface.bulkInsert(TABLE_NAME, data, {});
  20. },
  21. down: async (queryInterface, Sequelize) => {
  22. await queryInterface.bulkDelete(TABLE_NAME, null, {});
  23. },
  24. };