Closed raphaelsoul closed 1 year ago
https://github.com/edwardanthony/nestjs-seeder/blob/42435b8b4bfa3adfdb9469e428d2521825207c1b/lib/seeder/seeder.service.ts#L10
drop and seed is running parallelly. Some times drop is executed later
seed logs below
[Nest] 71391 - 11/12/2021, 10:15:36 AM VERBOSE [DatabaseLogger] QUERY: INSERT INTO "user_entity"("id", "username", "email", "realName", "password", "createdAt", "updatedAt", "deletedAt") VALUES (DEFAULT, $1, $2, $3, $4, $5, $6, DEFAULT), (DEFAULT, $7, $8, $9, $10, $11, $12, DEFAULT), (DEFAULT, $13, $14, $15, $16, $17, $18, DEFAULT), (DEFAULT, $19, $20, $21, $22, $23, $24, DEFAULT), (DEFAULT, $25, $26, $27, $28, $29, $30, DEFAULT), (DEFAULT, $31, $32, $33, $34, $35, $36, DEFAULT), (DEFAULT, $37, $38, $39, $40, $41, $42, DEFAULT), (DEFAULT, $43, $44, $45, $46, $47, $48, DEFAULT), (DEFAULT, $49, $50, $51, $52, $53, $54, DEFAULT), (DEFAULT, $55, $56, $57, $58, $59, $60, DEFAULT) RETURNING "id", "createdAt", "updatedAt", "deletedAt" - PARAMETERS: ["Zachery33","Ansley_Strosin@gmail.com","Layla O'Connell","ZpoQ4b3kQtmp2hb","2019-09-20T09:29:08.866Z","2021-08-21T15:53:42.908Z","Ara89","Lyda72@gmail.com","Amira Yost","eXR6jDQyUJFtStZ","2021-01-28T12:01:35.545Z","2021-10-07T20:18:28.332Z","Laney_Morar20","Shakira32@hotmail.com","Elisabeth McClure","jt8QyO9wlmvwZfd","2020-03-14T11:22:18.946Z","2021-01-03T06:58:04.940Z","Domenico_Nienow","Cornell38@yahoo.com","Abelardo Renner","kE4LFej0bVqEwXx","2019-03-11T03:11:45.895Z","2020-08-14T01:27:47.289Z","Samara_Prohaska","Lawrence_Hartmann@hotmail.com","Cristal Sanford","nFPXRmVE8lHBEEK","2021-02-12T07:25:06.748Z","2020-08-17T10:10:54.228Z","Lori41","Omari.Prosacco68@yahoo.com","Eddie Klein","AptXp33EAPCelf5","2019-06-22T14:44:49.606Z","2020-06-05T05:27:15.399Z","Breanna51","Faye58@gmail.com","Hettie Crist","cuVqgbavuW5grDI","2019-05-10T22:14:47.607Z","2020-10-20T20:06:17.335Z","Erica59","Iva18@gmail.com","Winona Bailey","aCOxRFe1KhfwKJx","2020-12-09T07:44:21.090Z","2020-10-27T06:17:15.609Z","Keith_Haley","Destinee.Lynch80@gmail.com","Madilyn Upton","BlOQWWqsI4Ss9T3","2021-02-03T00:43:54.026Z","2020-12-30T10:59:20.107Z","Tevin_Nikolaus","Sean.Douglas53@gmail.com","Alanna Stanton","EyorM4Cza06clFv","2019-10-30T18:23:47.188Z","2020-10-02T19:22:52.241Z"] UserSeeder completed [Nest] 71391 - 11/12/2021, 10:15:36 AM VERBOSE [DatabaseLogger] QUERY: DELETE FROM "user_entity" - PARAMETERS: []
We should use
async run(): Promise<any> { const promises = this.shouldRefresh() ? [this.drop().then(() => this.seed())] : [this.seed()]; return Promise.all(promises); }
https://github.com/edwardanthony/nestjs-seeder/blob/42435b8b4bfa3adfdb9469e428d2521825207c1b/lib/seeder/seeder.service.ts#L10
drop and seed is running parallelly. Some times drop is executed later
seed logs below
We should use