Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@astrojs/db] handle undefined snapshot from API #10378

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-snakes-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/db": patch
---

Handle new schema API response format
2 changes: 1 addition & 1 deletion packages/db/src/core/cli/commands/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions packages/db/src/core/cli/commands/verify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/core/cli/migration-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
Loading