diff --git a/.changeset/rotten-snakes-sip.md b/.changeset/rotten-snakes-sip.md new file mode 100644 index 0000000000..294efd246d --- /dev/null +++ b/.changeset/rotten-snakes-sip.md @@ -0,0 +1,5 @@ +--- +"@astrojs/db": patch +--- + +Handle new schema API response format diff --git a/packages/db/src/core/cli/commands/push/index.ts b/packages/db/src/core/cli/commands/push/index.ts index c847bc1eba..990ca05b91 100644 --- a/packages/db/src/core/cli/commands/push/index.ts +++ b/packages/db/src/core/cli/commands/push/index.ts @@ -25,7 +25,7 @@ export async function cmd({ const appToken = await getManagedAppTokenOrExit(flags.token); const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token }); const currentSnapshot = createCurrentSnapshot(dbConfig); - const isFromScratch = isForceReset || JSON.stringify(productionSnapshot) === '{}'; + const isFromScratch = isForceReset || !productionSnapshot; const { queries: migrationQueries, confirmations } = await getMigrationQueries({ oldSnapshot: isFromScratch ? createEmptySnapshot() : productionSnapshot, newSnapshot: currentSnapshot, diff --git a/packages/db/src/core/cli/commands/verify/index.ts b/packages/db/src/core/cli/commands/verify/index.ts index a83194599f..8c480344da 100644 --- a/packages/db/src/core/cli/commands/verify/index.ts +++ b/packages/db/src/core/cli/commands/verify/index.ts @@ -23,8 +23,7 @@ export async function cmd({ const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token }); const currentSnapshot = createCurrentSnapshot(dbConfig); const { queries: migrationQueries, confirmations } = await getMigrationQueries({ - oldSnapshot: - JSON.stringify(productionSnapshot) !== '{}' ? productionSnapshot : createEmptySnapshot(), + oldSnapshot: productionSnapshot || createEmptySnapshot(), newSnapshot: currentSnapshot, }); diff --git a/packages/db/src/core/cli/migration-queries.ts b/packages/db/src/core/cli/migration-queries.ts index 425e81b021..1cd9345aca 100644 --- a/packages/db/src/core/cli/migration-queries.ts +++ b/packages/db/src/core/cli/migration-queries.ts @@ -423,7 +423,7 @@ export async function getProductionCurrentSnapshot({ appToken, }: { appToken: string; -}): Promise { +}): Promise { const url = new URL('/db/schema', getRemoteDatabaseUrl()); const response = await fetch(url, {