File tree 6 files changed +51
-29
lines changed
6 files changed +51
-29
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @athenna/database" ,
3
- "version" : " 5.6 .0" ,
3
+ "version" : " 5.7 .0" ,
4
4
"description" : " The Athenna database handler for SQL/NoSQL." ,
5
5
"license" : " MIT" ,
6
6
"author" : " João Lenon <lenon@athenna.io>" ,
Original file line number Diff line number Diff line change @@ -36,11 +36,24 @@ export class DbWipeCommand extends BaseCommand {
36
36
await Artisan . call ( `db:wipe --connection ${ this . connection } ` )
37
37
console . log ( )
38
38
39
- await Artisan . call ( `migration:run --connection ${ this . connection } ` )
39
+ if ( this . getConfig ( 'driver' ) !== 'mongo' ) {
40
+ await Artisan . call ( `migration:run --connection ${ this . connection } ` )
41
+ }
40
42
41
43
if ( this . withSeeders ) {
42
44
console . log ( )
43
45
await Artisan . call ( `db:seed --connection ${ this . connection } ` )
44
46
}
45
47
}
48
+
49
+ private getConfig ( name : string , defaultValue ?: any ) {
50
+ return Config . get (
51
+ `database.connections.${
52
+ this . connection === 'default'
53
+ ? Config . get ( 'database.default' )
54
+ : this . connection
55
+ } .${ name } `,
56
+ defaultValue
57
+ )
58
+ }
46
59
}
Original file line number Diff line number Diff line change @@ -48,16 +48,16 @@ export class DbSeedCommand extends BaseCommand {
48
48
49
49
await DB . runSeeders ( { task, classes : this . classes } )
50
50
51
- await task . run ( ) . finally ( async ( ) => {
52
- const dbName = await DB . getCurrentDatabase ( )
53
-
54
- await DB . close ( )
55
-
56
- console . log ( )
57
- this . logger . success (
58
- `Database ({yellow} " ${ dbName } ") successfully seeded.`
59
- )
60
- } )
51
+ await task
52
+ . run ( )
53
+ . then ( async ( ) => {
54
+ const dbName = await DB . getCurrentDatabase ( )
55
+ console . log ( )
56
+ this . logger . success (
57
+ `Database ({yellow} " ${ dbName } ") successfully seeded.`
58
+ )
59
+ } )
60
+ . finally ( ( ) => DB . close ( ) )
61
61
}
62
62
63
63
private getConfig ( name : string , defaultValue ?: any ) {
Original file line number Diff line number Diff line change @@ -55,14 +55,17 @@ export class DbWipeCommand extends BaseCommand {
55
55
)
56
56
}
57
57
58
- await task . run ( ) . finally ( async ( ) => {
59
- const dbName = await DB . getCurrentDatabase ( )
58
+ await task
59
+ . run ( )
60
+ . then ( async ( ) => {
61
+ const dbName = await DB . getCurrentDatabase ( )
60
62
61
- await DB . close ( )
62
-
63
- console . log ( )
64
- this . logger . success ( `Database ({yellow} "${ dbName } ") successfully wiped.` )
65
- } )
63
+ console . log ( )
64
+ this . logger . success (
65
+ `Database ({yellow} "${ dbName } ") successfully wiped.`
66
+ )
67
+ } )
68
+ . finally ( ( ) => DB . close ( ) )
66
69
}
67
70
68
71
private getConfig ( name : string , defaultValue ?: any ) {
Original file line number Diff line number Diff line change @@ -38,12 +38,15 @@ export class MigrationRevertCommand extends BaseCommand {
38
38
}
39
39
40
40
const DB = Database . connection ( this . connection )
41
- const dbName = await DB . getCurrentDatabase ( )
42
41
43
- await DB . revertMigrations ( ) . finally ( ( ) => DB . close ( ) )
42
+ await DB . revertMigrations ( )
43
+ . then ( async ( ) => {
44
+ const dbName = await DB . getCurrentDatabase ( )
44
45
45
- this . logger . success (
46
- `Successfully reverted migrations on ({yellow} "${ dbName } ") database.`
47
- )
46
+ this . logger . success (
47
+ `Successfully reverted migrations on ({yellow} "${ dbName } ") database.`
48
+ )
49
+ } )
50
+ . finally ( ( ) => DB . close ( ) )
48
51
}
49
52
}
Original file line number Diff line number Diff line change @@ -38,12 +38,15 @@ export class MigrationRunCommand extends BaseCommand {
38
38
}
39
39
40
40
const DB = Database . connection ( this . connection )
41
- const dbName = await DB . getCurrentDatabase ( )
42
41
43
- await DB . runMigrations ( ) . finally ( ( ) => DB . close ( ) )
42
+ await DB . runMigrations ( )
43
+ . then ( async ( ) => {
44
+ const dbName = await DB . getCurrentDatabase ( )
44
45
45
- this . logger . success (
46
- `Successfully ran migrations on ({yellow} "${ dbName } ") database.`
47
- )
46
+ this . logger . success (
47
+ `Successfully ran migrations on ({yellow} "${ dbName } ") database.`
48
+ )
49
+ } )
50
+ . finally ( ( ) => DB . close ( ) )
48
51
}
49
52
}
You can’t perform that action at this time.
0 commit comments