Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(fresh): run operations inside task runner #158

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading