em-shop/users/migrations/20241120031944-add-users.js

34 lines
961 B
JavaScript
Raw Permalink Normal View History

2024-11-20 09:53:03 +05:00
'use strict';
module.exports = {
up: async (queryInterface) => {
const count = 1000000;
const chunkSize = 10000;
for (let i = 0; i < count; i += chunkSize) {
const users = Array.from(
{ length: Math.min(chunkSize, count - i) },
() => ({
firstName:
'Firstname_' +
(Math.floor(Math.random() * 9_000_000_000) + 1_000_000_000),
lastName:
'Lastname_' +
(Math.floor(Math.random() * 9_000_000_000) + 1_000_000_000),
birthday: '2006-11-19 19:00:00.000 +00:00',
sex: Math.floor(Math.random() * 2) + 1,
problems: Math.random() < 0.5,
createdAt: '2006-11-19 19:00:00.000 +00:00',
updatedAt: '2006-11-19 19:00:00.000 +00:00',
}),
);
await queryInterface.bulkInsert('user', users, {});
}
},
down: async (queryInterface) => {
await queryInterface.bulkDelete('user', null, {});
},
};