@keltoi/hydra 2.3.4 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -358,7 +358,11 @@ class Migration{
|
|
|
358
358
|
.#db('migration')
|
|
359
359
|
.where({ name })
|
|
360
360
|
.update({ iteration })
|
|
361
|
-
.
|
|
361
|
+
.then(affected=>{
|
|
362
|
+
if (affected == 0) return this
|
|
363
|
+
.#db('migration')
|
|
364
|
+
.insert({ iteration,name })
|
|
365
|
+
})
|
|
362
366
|
|
|
363
367
|
async runMigrations({ entity = Entity, migrations=[async ()=>{}] }){
|
|
364
368
|
const name = entity.name;
|
|
@@ -369,7 +373,9 @@ class Migration{
|
|
|
369
373
|
|
|
370
374
|
if (iteration >= listSize) return
|
|
371
375
|
|
|
372
|
-
for (let index = iteration; index < listSize; index++)
|
|
376
|
+
for (let index = iteration; index < listSize; index++)
|
|
377
|
+
await migrations[index]()
|
|
378
|
+
.catch(err=>console.log(err));
|
|
373
379
|
|
|
374
380
|
await this.#update({ iteration:listSize,name });
|
|
375
381
|
}
|
|
@@ -425,9 +431,13 @@ let Context$2 = class Context{
|
|
|
425
431
|
const migration = new Migration(this.#db);
|
|
426
432
|
|
|
427
433
|
const promises = models.map(model=>
|
|
428
|
-
model
|
|
434
|
+
model
|
|
435
|
+
.structMe(this.#db)
|
|
429
436
|
.then(()=>migration
|
|
430
|
-
.runMigrations({
|
|
437
|
+
.runMigrations({
|
|
438
|
+
entity: model,
|
|
439
|
+
migrations: model.migrations(this.#db)
|
|
440
|
+
})
|
|
431
441
|
)
|
|
432
442
|
);
|
|
433
443
|
|