( schemaPath: string | string[], verbose: boolean, strict: boolean, credentials: SqliteCredentials, tablesFilter: string[], force: boolean, casing: CasingType | undefined, )
| 411 | }; |
| 412 | |
| 413 | export const sqlitePush = async ( |
| 414 | schemaPath: string | string[], |
| 415 | verbose: boolean, |
| 416 | strict: boolean, |
| 417 | credentials: SqliteCredentials, |
| 418 | tablesFilter: string[], |
| 419 | force: boolean, |
| 420 | casing: CasingType | undefined, |
| 421 | ) => { |
| 422 | const { connectToSQLite } = await import('../connections'); |
| 423 | const { sqlitePushIntrospect } = await import('./sqliteIntrospect'); |
| 424 | |
| 425 | const db = await connectToSQLite(credentials); |
| 426 | const { schema } = await sqlitePushIntrospect(db, tablesFilter); |
| 427 | const { prepareSQLitePush } = await import('./migrate'); |
| 428 | |
| 429 | const statements = await prepareSQLitePush(schemaPath, schema, casing); |
| 430 | |
| 431 | if (statements.sqlStatements.length === 0) { |
| 432 | render(`\n[${chalk.blue('i')}] No changes detected`); |
| 433 | } else { |
| 434 | const { |
| 435 | shouldAskForApprove, |
| 436 | statementsToExecute, |
| 437 | columnsToRemove, |
| 438 | tablesToRemove, |
| 439 | tablesToTruncate, |
| 440 | infoToPrint, |
| 441 | schemasToRemove, |
| 442 | } = await sqliteSuggestions( |
| 443 | db, |
| 444 | statements.statements, |
| 445 | statements.squashedPrev, |
| 446 | statements.squashedCur, |
| 447 | statements.meta!, |
| 448 | ); |
| 449 | |
| 450 | if (verbose && statementsToExecute.length > 0) { |
| 451 | console.log(); |
| 452 | console.log( |
| 453 | withStyle.warning('You are about to execute current statements:'), |
| 454 | ); |
| 455 | console.log(); |
| 456 | console.log(statementsToExecute.map((s) => chalk.blue(s)).join('\n')); |
| 457 | console.log(); |
| 458 | } |
| 459 | |
| 460 | if (!force && strict) { |
| 461 | if (!shouldAskForApprove) { |
| 462 | const { status, data } = await render( |
| 463 | new Select(['No, abort', `Yes, I want to execute all statements`]), |
| 464 | ); |
| 465 | if (data?.index === 0) { |
| 466 | render(`[${chalk.red('x')}] All changes were aborted`); |
| 467 | process.exit(0); |
| 468 | } |
| 469 | } |
| 470 | } |
no test coverage detected