From 1fbdb2aef5fe39d0b191ab493a18e45003828b87 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Sun, 28 Apr 2024 10:46:22 +0100 Subject: [PATCH] chore(fresh): run operations inside task runner --- package-lock.json | 4 ++-- package.json | 2 +- src/commands/DbFreshCommand.ts | 1 + src/commands/DbWipeCommand.ts | 10 +++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5ea40c0..e72b2ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/database", - "version": "4.47.0", + "version": "4.48.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/database", - "version": "4.47.0", + "version": "4.48.0", "license": "MIT", "dependencies": { "@faker-js/faker": "^8.4.0", diff --git a/package.json b/package.json index e67954c..538a509 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/database", - "version": "4.47.0", + "version": "4.48.0", "description": "The Athenna database handler for SQL/NoSQL.", "license": "MIT", "author": "João Lenon ", diff --git a/src/commands/DbFreshCommand.ts b/src/commands/DbFreshCommand.ts index d3adbfa..963c0c6 100644 --- a/src/commands/DbFreshCommand.ts +++ b/src/commands/DbFreshCommand.ts @@ -35,6 +35,7 @@ export class DbWipeCommand extends BaseCommand { public async handle(): Promise { await Artisan.call(`db:wipe --connection ${this.connection}`) console.log() + await Artisan.call(`migration:run --connection ${this.connection}`) if (this.withSeeders) { diff --git a/src/commands/DbWipeCommand.ts b/src/commands/DbWipeCommand.ts index cb10d79..926ec59 100644 --- a/src/commands/DbWipeCommand.ts +++ b/src/commands/DbWipeCommand.ts @@ -36,15 +36,19 @@ export class DbWipeCommand extends BaseCommand { if (this.getConfig('driver') === 'mongo') { const tables = await DB.getTables() - await Exec.concurrently(tables, table => DB.dropTable(table)) + task.addPromise('Dropping all database tables', () => { + return Exec.concurrently(tables, table => DB.dropTable(table)) + }) } else { const migrationsTable = this.getConfig( 'migrations.tableName', 'migrations' ) - await DB.revertMigrations() - await DB.dropTable(migrationsTable) + task.addPromise('Reverting migrations', () => DB.revertMigrations()) + task.addPromise('Drop migrations table', () => + DB.dropTable(migrationsTable) + ) } const dbName = await DB.getCurrentDatabase()