(config: GenerateConfig)
| 800 | }; |
| 801 | |
| 802 | export const prepareAndMigrateSqlite = async (config: GenerateConfig) => { |
| 803 | const outFolder = config.out; |
| 804 | const schemaPath = config.schema; |
| 805 | const casing = config.casing; |
| 806 | |
| 807 | try { |
| 808 | assertV1OutFolder(outFolder); |
| 809 | |
| 810 | const { snapshots, journal } = prepareMigrationFolder(outFolder, 'sqlite'); |
| 811 | const { prev, cur, custom } = await prepareSqliteMigrationSnapshot( |
| 812 | snapshots, |
| 813 | schemaPath, |
| 814 | casing, |
| 815 | ); |
| 816 | |
| 817 | const validatedPrev = sqliteSchema.parse(prev); |
| 818 | const validatedCur = sqliteSchema.parse(cur); |
| 819 | |
| 820 | if (config.custom) { |
| 821 | writeResult({ |
| 822 | cur: custom, |
| 823 | sqlStatements: [], |
| 824 | journal, |
| 825 | outFolder, |
| 826 | name: config.name, |
| 827 | breakpoints: config.breakpoints, |
| 828 | bundle: config.bundle, |
| 829 | type: 'custom', |
| 830 | prefixMode: config.prefix, |
| 831 | }); |
| 832 | return; |
| 833 | } |
| 834 | |
| 835 | const squashedPrev = squashSqliteScheme(validatedPrev); |
| 836 | const squashedCur = squashSqliteScheme(validatedCur); |
| 837 | |
| 838 | const { sqlStatements, _meta } = await applySqliteSnapshotsDiff( |
| 839 | squashedPrev, |
| 840 | squashedCur, |
| 841 | tablesResolver, |
| 842 | columnsResolver, |
| 843 | sqliteViewsResolver, |
| 844 | validatedPrev, |
| 845 | validatedCur, |
| 846 | ); |
| 847 | |
| 848 | writeResult({ |
| 849 | cur, |
| 850 | sqlStatements, |
| 851 | journal, |
| 852 | _meta, |
| 853 | outFolder, |
| 854 | name: config.name, |
| 855 | breakpoints: config.breakpoints, |
| 856 | bundle: config.bundle, |
| 857 | prefixMode: config.prefix, |
| 858 | driver: config.driver, |
| 859 | }); |
no test coverage detected