11import { Args , Flags } from '@oclif/core' ;
22import { Schemas } from '@xata.io/client' ;
3+ import { PgRollMigrationDefinition } from '@xata.io/pgroll' ;
34import { BaseCommand } from '../../base.js' ;
45import {
56 LocalMigrationFile ,
@@ -11,10 +12,10 @@ import {
1112 allMigrationsPgRollFormat ,
1213 getBranchDetailsWithPgRoll ,
1314 isBranchPgRollEnabled ,
14- isMigrationPgRollFormat
15+ isMigrationPgRollFormat ,
16+ waitForMigrationToFinish
1517} from '../../migrations/pgroll.js' ;
1618import { MigrationFilePgroll } from '../../migrations/schema.js' ;
17- import { PgRollMigrationDefinition } from '@xata.io/pgroll' ;
1819
1920export default class Push extends BaseCommand < typeof Push > {
2021 static description = 'Push local changes to a remote Xata branch' ;
@@ -103,10 +104,12 @@ export default class Push extends BaseCommand<typeof Push> {
103104 . flatMap ( ( migration ) => PgRollMigrationDefinition . parse ( migration ) ) ;
104105 for ( const migration of migrationsToPush ) {
105106 try {
106- await xata . api . migrations . applyMigration ( {
107+ const { jobID } = await xata . api . migrations . applyMigration ( {
107108 pathParams : { workspace, region, dbBranchName : `${ database } :${ branch } ` } ,
108109 body : migration
109110 } ) ;
111+
112+ await waitForMigrationToFinish ( xata . api , workspace , region , database , branch , jobID ) ;
110113 } catch ( e ) {
111114 this . log ( `Failed to push ${ migration } with ${ e } . Stopping.` ) ;
112115 this . exit ( 1 ) ;
0 commit comments