@@ -1160,41 +1160,35 @@ export class PostgresStorageAdapter {
1160
1160
}
1161
1161
1162
1162
performInitialization ( { VolatileClassesSchemas } ) {
1163
- const now = new Date ( ) . getTime ( ) ;
1164
1163
debug ( 'performInitialization' ) ;
1165
- let promises = VolatileClassesSchemas . map ( ( schema ) => {
1166
- return this . createTable ( schema . className , schema ) . catch ( ( err ) => {
1164
+ const promises = VolatileClassesSchemas . map ( ( schema ) => {
1165
+ return this . createTable ( schema . className , schema ) . catch ( ( err ) => {
1167
1166
if ( err . code === PostgresDuplicateRelationError || err . code === Parse . Error . INVALID_CLASS_NAME ) {
1168
1167
return Promise . resolve ( ) ;
1169
1168
}
1170
1169
throw err ;
1171
1170
} ) ;
1172
1171
} ) ;
1173
- /* eslint-disable no-console */
1174
- promises = promises . concat ( [
1175
- this . _client . none ( sql . misc . jsonObjectSetKeys ) . catch ( ( err ) => {
1176
- console . error ( err ) ;
1177
- } ) ,
1178
- this . _client . none ( sql . array . add ) . catch ( ( err ) => {
1179
- console . error ( err ) ;
1180
- } ) ,
1181
- this . _client . none ( sql . array . addUnique ) . catch ( ( err ) => {
1182
- console . error ( err ) ;
1183
- } ) ,
1184
- this . _client . none ( sql . array . remove ) . catch ( ( err ) => {
1185
- console . error ( err ) ;
1186
- } ) ,
1187
- this . _client . none ( sql . array . containsAll ) . catch ( ( err ) => {
1188
- console . error ( err ) ;
1189
- } ) ,
1190
- this . _client . none ( sql . array . contains ) . catch ( ( err ) => {
1191
- console . error ( err ) ;
1172
+ return Promise . all ( promises )
1173
+ . then ( ( ) => {
1174
+ return this . _client . tx ( t => {
1175
+ return t . batch ( [
1176
+ t . none ( sql . misc . jsonObjectSetKeys ) ,
1177
+ t . none ( sql . array . add ) ,
1178
+ t . none ( sql . array . addUnique ) ,
1179
+ t . none ( sql . array . remove ) ,
1180
+ t . none ( sql . array . containsAll ) ,
1181
+ t . none ( sql . array . contains )
1182
+ ] ) ;
1183
+ } ) ;
1184
+ } )
1185
+ . then ( data => {
1186
+ debug ( `initializationDone in ${ data . duration } ` ) ;
1192
1187
} )
1193
- ] ) ;
1194
- /* eslint-enable no-console */
1195
- return Promise . all ( promises ) . then ( ( ) => {
1196
- debug ( `initialzationDone in ${ new Date ( ) . getTime ( ) - now } ` ) ;
1197
- } , ( ) => { } ) ;
1188
+ . catch ( error => {
1189
+ /* eslint-disable no-console */
1190
+ console . error ( error ) ;
1191
+ } ) ;
1198
1192
}
1199
1193
}
1200
1194
0 commit comments