@@ -843,35 +843,26 @@ export class PostgresStorageAdapter implements StorageAdapter {
843
843
// Returns a Promise.
844
844
deleteFields ( className : string , schema : SchemaType , fieldNames : string [ ] ) : Promise < void > {
845
845
debug ( 'deleteFields' , className , fieldNames ) ;
846
- return Promise . resolve ( )
847
- . then ( ( ) => {
848
- fieldNames = fieldNames . reduce ( ( list : string [ ] , fieldName : string ) => {
849
- const field = schema . fields [ fieldName ]
850
- if ( field . type !== 'Relation' ) {
851
- list . push ( fieldName ) ;
852
- }
853
- delete schema . fields [ fieldName ] ;
854
- return list ;
855
- } , [ ] ) ;
856
-
857
- const values = [ className , ...fieldNames ] ;
858
- const columns = fieldNames . map ( ( name , idx ) => {
859
- return `$${ idx + 2 } :name` ;
860
- } ) . join ( ', DROP COLUMN' ) ;
861
-
862
- const doBatch = ( t ) => {
863
- const batch = [
864
- t . none ( 'UPDATE "_SCHEMA" SET "schema"=$<schema> WHERE "className"=$<className>' , { schema, className} )
865
- ] ;
866
- if ( values . length > 1 ) {
867
- batch . push ( t . none ( `ALTER TABLE $1:name DROP COLUMN ${ columns } ` , values ) ) ;
868
- }
869
- return batch ;
870
- }
871
- return this . _client . tx ( ( t ) => {
872
- return t . batch ( doBatch ( t ) ) ;
873
- } ) ;
874
- } ) ;
846
+ fieldNames = fieldNames . reduce ( ( list , fieldName ) => {
847
+ const field = schema . fields [ fieldName ]
848
+ if ( field . type !== 'Relation' ) {
849
+ list . push ( fieldName ) ;
850
+ }
851
+ delete schema . fields [ fieldName ] ;
852
+ return list ;
853
+ } , [ ] ) ;
854
+
855
+ const values = [ className , ...fieldNames ] ;
856
+ const columns = fieldNames . map ( ( name , idx ) => {
857
+ return `$${ idx + 2 } :name` ;
858
+ } ) . join ( ', DROP COLUMN' ) ;
859
+
860
+ return this . _client . tx ( 'delete-fields' , function * ( t ) {
861
+ yield t . none ( 'UPDATE "_SCHEMA" SET "schema"=$<schema> WHERE "className"=$<className>' , { schema, className} ) ;
862
+ if ( values . length > 1 ) {
863
+ yield t . none ( `ALTER TABLE $1:name DROP COLUMN ${ columns } ` , values ) ;
864
+ }
865
+ } ) ;
875
866
}
876
867
877
868
// Return a promise for all schemas known to this adapter, in Parse format. In case the
0 commit comments