cmd() — astro Function Reference
Architecture documentation for the cmd() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 5b9ae329_75d0_aca2_14b6_dde81b7fd73b["cmd()"] d792b779_355c_47a7_c602_04c8b8882820["index.ts"] 5b9ae329_75d0_aca2_14b6_dde81b7fd73b -->|defined in| d792b779_355c_47a7_c602_04c8b8882820 87af403c_099b_77aa_edce_f10307a1f2a4["pushSchema()"] 5b9ae329_75d0_aca2_14b6_dde81b7fd73b -->|calls| 87af403c_099b_77aa_edce_f10307a1f2a4 style 5b9ae329_75d0_aca2_14b6_dde81b7fd73b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/db/src/core/cli/commands/push/index.ts lines 21–81
export async function cmd({
dbConfig,
flags,
}: {
astroConfig: AstroConfig;
dbConfig: DBConfig;
flags: Arguments;
}) {
const isDryRun = flags.dryRun;
const isForceReset = flags.forceReset;
const dbInfo = getRemoteDatabaseInfo();
const appToken = resolveDbAppToken(flags, dbInfo.token);
const productionSnapshot = await getProductionCurrentSnapshot({ ...dbInfo, token: appToken });
const currentSnapshot = createCurrentSnapshot(dbConfig);
const isFromScratch = !productionSnapshot;
const { queries: migrationQueries, confirmations } = await getMigrationQueries({
oldSnapshot: isFromScratch ? createEmptySnapshot() : productionSnapshot,
newSnapshot: currentSnapshot,
reset: isForceReset,
});
// // push the database schema
if (migrationQueries.length === 0) {
console.log('Database schema is up to date.');
} else {
console.log(`Database schema is out of date.`);
}
if (isForceReset) {
const { begin } = await prompts({
type: 'confirm',
name: 'begin',
message: `Reset your database? All of your data will be erased and your schema created from scratch.`,
initial: false,
});
if (!begin) {
console.log('Canceled.');
process.exit(0);
}
console.log(`Force-pushing to the database. All existing data will be erased.`);
} else if (confirmations.length > 0) {
console.log('\n' + formatDataLossMessage(confirmations) + '\n');
throw new Error('Exiting.');
}
if (isDryRun) {
console.log('Statements:', JSON.stringify(migrationQueries, undefined, 2));
} else {
console.log(`Pushing database schema updates...`);
await pushSchema({
statements: migrationQueries,
dbInfo,
appToken,
isDryRun,
currentSnapshot: currentSnapshot,
});
}
console.info('Push complete!');
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does cmd() do?
cmd() is a function in the astro codebase, defined in packages/db/src/core/cli/commands/push/index.ts.
Where is cmd() defined?
cmd() is defined in packages/db/src/core/cli/commands/push/index.ts at line 21.
What does cmd() call?
cmd() calls 1 function(s): pushSchema.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free