MCPcopy
hub / github.com/drizzle-team/drizzle-orm / libSQLPush

Function libSQLPush

drizzle-kit/src/cli/commands/push.ts:534–639  ·  view source on GitHub ↗
(
	schemaPath: string | string[],
	verbose: boolean,
	strict: boolean,
	credentials: LibSQLCredentials,
	tablesFilter: string[],
	force: boolean,
	casing: CasingType | undefined,
)

Source from the content-addressed store, hash-verified

532};
533
534export const libSQLPush = async (
535 schemaPath: string | string[],
536 verbose: boolean,
537 strict: boolean,
538 credentials: LibSQLCredentials,
539 tablesFilter: string[],
540 force: boolean,
541 casing: CasingType | undefined,
542) => {
543 const { connectToLibSQL } = await import('../connections');
544 const { sqlitePushIntrospect } = await import('./sqliteIntrospect');
545
546 const db = await connectToLibSQL(credentials);
547 const { schema } = await sqlitePushIntrospect(db, tablesFilter);
548
549 const { prepareLibSQLPush } = await import('./migrate');
550
551 const statements = await prepareLibSQLPush(schemaPath, schema, casing);
552
553 if (statements.sqlStatements.length === 0) {
554 render(`\n[${chalk.blue('i')}] No changes detected`);
555 } else {
556 const {
557 shouldAskForApprove,
558 statementsToExecute,
559 columnsToRemove,
560 tablesToRemove,
561 tablesToTruncate,
562 infoToPrint,
563 } = await libSqlLogSuggestionsAndReturn(
564 db,
565 statements.statements,
566 statements.squashedPrev,
567 statements.squashedCur,
568 statements.meta!,
569 );
570
571 if (verbose && statementsToExecute.length > 0) {
572 console.log();
573 console.log(
574 withStyle.warning('You are about to execute current statements:'),
575 );
576 console.log();
577 console.log(statementsToExecute.map((s) => chalk.blue(s)).join('\n'));
578 console.log();
579 }
580
581 if (!force && strict) {
582 if (!shouldAskForApprove) {
583 const { status, data } = await render(
584 new Select(['No, abort', `Yes, I want to execute all statements`]),
585 );
586 if (data?.index === 0) {
587 render(`[${chalk.red('x')}] All changes were aborted`);
588 process.exit(0);
589 }
590 }
591 }

Callers 1

schema.tsFile · 0.85

Calls 4

connectToLibSQLFunction · 0.85
sqlitePushIntrospectFunction · 0.85
prepareLibSQLPushFunction · 0.85

Tested by

no test coverage detected