diff options
-rw-r--r-- | .changeset/rotten-snakes-sip.md | 5 | ||||
-rw-r--r-- | packages/db/src/core/cli/commands/push/index.ts | 2 | ||||
-rw-r--r-- | packages/db/src/core/cli/commands/verify/index.ts | 3 | ||||
-rw-r--r-- | packages/db/src/core/cli/migration-queries.ts | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/.changeset/rotten-snakes-sip.md b/.changeset/rotten-snakes-sip.md new file mode 100644 index 000000000..294efd246 --- /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 c847bc1eb..990ca05b9 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 a83194599..8c480344d 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 425e81b02..1cd9345ac 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<DBSnapshot> { +}): Promise<DBSnapshot | undefined> { const url = new URL('/db/schema', getRemoteDatabaseUrl()); const response = await fetch(url, { |