0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

handle undefined snapshot from API (#10378)

This commit is contained in:
Fred K. Schott 2024-03-10 23:56:01 -07:00 committed by GitHub
parent dfdf6b3a0b
commit 41dca1e413
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
"@astrojs/db": patch
---
Handle new schema API response format

View file

@ -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,

View file

@ -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,
});

View file

@ -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, {