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:
parent
dfdf6b3a0b
commit
41dca1e413
4 changed files with 8 additions and 4 deletions
5
.changeset/rotten-snakes-sip.md
Normal file
5
.changeset/rotten-snakes-sip.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@astrojs/db": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handle new schema API response format
|
|
@ -25,7 +25,7 @@ export async function cmd({
|
||||||
const appToken = await getManagedAppTokenOrExit(flags.token);
|
const appToken = await getManagedAppTokenOrExit(flags.token);
|
||||||
const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token });
|
const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token });
|
||||||
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
||||||
const isFromScratch = isForceReset || JSON.stringify(productionSnapshot) === '{}';
|
const isFromScratch = isForceReset || !productionSnapshot;
|
||||||
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
||||||
oldSnapshot: isFromScratch ? createEmptySnapshot() : productionSnapshot,
|
oldSnapshot: isFromScratch ? createEmptySnapshot() : productionSnapshot,
|
||||||
newSnapshot: currentSnapshot,
|
newSnapshot: currentSnapshot,
|
||||||
|
|
|
@ -23,8 +23,7 @@ export async function cmd({
|
||||||
const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token });
|
const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token });
|
||||||
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
const currentSnapshot = createCurrentSnapshot(dbConfig);
|
||||||
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
|
||||||
oldSnapshot:
|
oldSnapshot: productionSnapshot || createEmptySnapshot(),
|
||||||
JSON.stringify(productionSnapshot) !== '{}' ? productionSnapshot : createEmptySnapshot(),
|
|
||||||
newSnapshot: currentSnapshot,
|
newSnapshot: currentSnapshot,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ export async function getProductionCurrentSnapshot({
|
||||||
appToken,
|
appToken,
|
||||||
}: {
|
}: {
|
||||||
appToken: string;
|
appToken: string;
|
||||||
}): Promise<DBSnapshot> {
|
}): Promise<DBSnapshot | undefined> {
|
||||||
const url = new URL('/db/schema', getRemoteDatabaseUrl());
|
const url = new URL('/db/schema', getRemoteDatabaseUrl());
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
|
Loading…
Reference in a new issue