File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ declare module '@ioc:Zakodium/Mongodb/Migration' {
24
24
callback : ( db : Db , client : ClientSession ) => Promise < void > ,
25
25
) : void ;
26
26
public abstract up ( ) : void ;
27
+ public afterUpSuccess ?( ) : unknown ;
27
28
public execUp ( session : ClientSession ) : Promise < void > ;
28
29
}
29
30
}
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ import { inject } from '@adonisjs/core/build/standalone';
2
2
import { ObjectId } from 'mongodb' ;
3
3
4
4
import { DatabaseContract } from '@ioc:Zakodium/Mongodb/Database' ;
5
+ import Migration from '@ioc:Zakodium/Mongodb/Migration' ;
5
6
6
7
import MigrationCommand , {
7
8
migrationCollectionName ,
8
9
migrationLockCollectionName ,
9
10
} from './util/MigrationCommand' ;
10
- import Migration from '@ioc:Zakodium/Mongodb/Migration' ;
11
11
12
12
interface IMigration {
13
13
_id : ObjectId | undefined ;
@@ -123,6 +123,17 @@ export default class MongodbMigrate extends MigrationCommand {
123
123
break ;
124
124
}
125
125
126
+ if ( migration . afterUpSuccess ) {
127
+ try {
128
+ await migration . afterUpSuccess ( ) ;
129
+ } catch ( error ) {
130
+ this . logger . warning ( `Migration's afterUpSuccess call failed` ) ;
131
+ // TODO: See if there can be a way in Ace commands to print error stack traces
132
+ // eslint-disable-next-line no-console
133
+ console . warn ( error ) ;
134
+ }
135
+ }
136
+
126
137
successfullyExecuted ++ ;
127
138
}
128
139
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ export default function createMigration(Database: DatabaseContract): any {
173
173
}
174
174
175
175
public abstract up ( ) : void ;
176
+ public afterUpSuccess ?( ) : void ;
176
177
}
177
178
178
179
return Migration ;
You can’t perform that action at this time.
0 commit comments