(config: GenerateConfig)
| 525 | }; |
| 526 | |
| 527 | export const prepareAndMigrateMysql = async (config: GenerateConfig) => { |
| 528 | const outFolder = config.out; |
| 529 | const schemaPath = config.schema; |
| 530 | const casing = config.casing; |
| 531 | |
| 532 | try { |
| 533 | // TODO: remove |
| 534 | assertV1OutFolder(outFolder); |
| 535 | |
| 536 | const { snapshots, journal } = prepareMigrationFolder(outFolder, 'mysql'); |
| 537 | const { prev, cur, custom } = await prepareMySqlMigrationSnapshot( |
| 538 | snapshots, |
| 539 | schemaPath, |
| 540 | casing, |
| 541 | ); |
| 542 | |
| 543 | const validatedPrev = mysqlSchema.parse(prev); |
| 544 | const validatedCur = mysqlSchema.parse(cur); |
| 545 | |
| 546 | if (config.custom) { |
| 547 | writeResult({ |
| 548 | cur: custom, |
| 549 | sqlStatements: [], |
| 550 | journal, |
| 551 | outFolder, |
| 552 | name: config.name, |
| 553 | breakpoints: config.breakpoints, |
| 554 | type: 'custom', |
| 555 | prefixMode: config.prefix, |
| 556 | }); |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | const squashedPrev = squashMysqlScheme(validatedPrev); |
| 561 | const squashedCur = squashMysqlScheme(validatedCur); |
| 562 | |
| 563 | const { sqlStatements, statements, _meta } = await applyMysqlSnapshotsDiff( |
| 564 | squashedPrev, |
| 565 | squashedCur, |
| 566 | tablesResolver, |
| 567 | columnsResolver, |
| 568 | mySqlViewsResolver, |
| 569 | validatedPrev, |
| 570 | validatedCur, |
| 571 | ); |
| 572 | |
| 573 | writeResult({ |
| 574 | cur, |
| 575 | sqlStatements, |
| 576 | journal, |
| 577 | _meta, |
| 578 | outFolder, |
| 579 | name: config.name, |
| 580 | breakpoints: config.breakpoints, |
| 581 | prefixMode: config.prefix, |
| 582 | }); |
| 583 | } catch (e) { |
| 584 | console.error(e); |
no test coverage detected