Skip to content

Commit

Permalink
feat: add schema param to apply request on push (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemmiillyy authored Jul 11, 2024
1 parent 40f97d5 commit 6d6c963
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cli/src/commands/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ export default class Push extends BaseCommand<typeof Push> {
if (!confirm) return this.exit(1);

if (isBranchPgRollEnabled(details)) {
const migrationsToPush = (newMigrations as MigrationFilePgroll[])
.map(({ migration }) => migration)
.flatMap((migration) => PgRollMigrationDefinition.parse(migration));
const migrationsToPush = (newMigrations as MigrationFilePgroll[]).map(({ migration, schema }) => ({
operations: PgRollMigrationDefinition.parse(migration),
schema
}));
for (const migration of migrationsToPush) {
try {
const { jobID } = await xata.api.migrations.applyMigration({
pathParams: { workspace, region, dbBranchName: `${database}:${branch}` },
body: migration
body: { ...migration.operations, schema: migration.schema }
});

await waitForMigrationToFinish(xata.api, workspace, region, database, branch, jobID);
Expand Down
3 changes: 2 additions & 1 deletion cli/src/migrations/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const migrationFilePgroll = z.object({
parent: z.string().optional(),
migration: PgRollMigrationDefinition,
done: z.boolean(),
migrationType: z.enum(['pgroll', 'inferred']) satisfies z.ZodType<Schemas.MigrationType>
migrationType: z.enum(['pgroll', 'inferred']) satisfies z.ZodType<Schemas.MigrationType>,
schema: z.string()
});

export type MigrationFilePgroll = z.infer<typeof migrationFilePgroll>;

0 comments on commit 6d6c963

Please sign in to comment.