Skip to content

Commit

Permalink
Merge pull request #158 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(fresh): run operations inside task runner
  • Loading branch information
jlenon7 authored Apr 28, 2024
2 parents 82bb5e3 + 1fbdb2a commit bd4939b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions src/commands/DbFreshCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class DbWipeCommand extends BaseCommand {
public async handle(): Promise<void> {
await Artisan.call(`db:wipe --connection ${this.connection}`)
console.log()

await Artisan.call(`migration:run --connection ${this.connection}`)

if (this.withSeeders) {
Expand Down
10 changes: 7 additions & 3 deletions src/commands/DbWipeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit bd4939b

Please sign in to comment.