getDbCurrentSnapshot() — astro Function Reference
Architecture documentation for the getDbCurrentSnapshot() function in migration-queries.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 10b202a7_40ec_789d_58db_f2a0faad5305["getDbCurrentSnapshot()"] d1459290_7e42_1f92_05bd_dcc3aeda9fd3["migration-queries.ts"] 10b202a7_40ec_789d_58db_f2a0faad5305 -->|defined in| d1459290_7e42_1f92_05bd_dcc3aeda9fd3 a2471c30_5272_46a9_cb79_2b86d12f6d5b["getProductionCurrentSnapshot()"] a2471c30_5272_46a9_cb79_2b86d12f6d5b -->|calls| 10b202a7_40ec_789d_58db_f2a0faad5305 style 10b202a7_40ec_789d_58db_f2a0faad5305 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/db/src/core/cli/migration-queries.ts lines 433–470
async function getDbCurrentSnapshot(
appToken: string,
remoteUrl: string,
): Promise<DBSnapshot | undefined> {
const client = createClient({
token: appToken,
url: remoteUrl,
});
try {
const res = await client.get<{ snapshot: string }>(
// Latest snapshot
sql`select snapshot from _astro_db_snapshot order by id desc limit 1;`,
);
return JSON.parse(res.snapshot);
} catch (error) {
// Don't handle errors that are not from libSQL
if (
isDbError(error) &&
// If the schema was never pushed to the database yet the table won't exist.
// Treat a missing snapshot table as an empty table.
// When connecting to a remote database in that condition
// the query will fail with the following error code and message.
((error.code === 'SQLITE_UNKNOWN' &&
error.message === 'SQLITE_UNKNOWN: SQLite error: no such table: _astro_db_snapshot') ||
// When connecting to a local or in-memory database that does not have a snapshot table yet
// the query will fail with the following error code and message.
(error.code === 'SQLITE_ERROR' &&
error.message === 'SQLITE_ERROR: no such table: _astro_db_snapshot'))
) {
return;
}
throw error;
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getDbCurrentSnapshot() do?
getDbCurrentSnapshot() is a function in the astro codebase, defined in packages/db/src/core/cli/migration-queries.ts.
Where is getDbCurrentSnapshot() defined?
getDbCurrentSnapshot() is defined in packages/db/src/core/cli/migration-queries.ts at line 433.
What calls getDbCurrentSnapshot()?
getDbCurrentSnapshot() is called by 1 function(s): getProductionCurrentSnapshot.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free