(config: GenerateConfig)
| 895 | }; |
| 896 | |
| 897 | export const prepareAndMigrateLibSQL = async (config: GenerateConfig) => { |
| 898 | const outFolder = config.out; |
| 899 | const schemaPath = config.schema; |
| 900 | const casing = config.casing; |
| 901 | |
| 902 | try { |
| 903 | assertV1OutFolder(outFolder); |
| 904 | |
| 905 | const { snapshots, journal } = prepareMigrationFolder(outFolder, 'sqlite'); |
| 906 | const { prev, cur, custom } = await prepareSqliteMigrationSnapshot( |
| 907 | snapshots, |
| 908 | schemaPath, |
| 909 | casing, |
| 910 | ); |
| 911 | |
| 912 | const validatedPrev = sqliteSchema.parse(prev); |
| 913 | const validatedCur = sqliteSchema.parse(cur); |
| 914 | |
| 915 | if (config.custom) { |
| 916 | writeResult({ |
| 917 | cur: custom, |
| 918 | sqlStatements: [], |
| 919 | journal, |
| 920 | outFolder, |
| 921 | name: config.name, |
| 922 | breakpoints: config.breakpoints, |
| 923 | bundle: config.bundle, |
| 924 | type: 'custom', |
| 925 | prefixMode: config.prefix, |
| 926 | }); |
| 927 | return; |
| 928 | } |
| 929 | |
| 930 | const squashedPrev = squashSqliteScheme(validatedPrev); |
| 931 | const squashedCur = squashSqliteScheme(validatedCur); |
| 932 | |
| 933 | const { sqlStatements, _meta } = await applyLibSQLSnapshotsDiff( |
| 934 | squashedPrev, |
| 935 | squashedCur, |
| 936 | tablesResolver, |
| 937 | columnsResolver, |
| 938 | sqliteViewsResolver, |
| 939 | validatedPrev, |
| 940 | validatedCur, |
| 941 | ); |
| 942 | |
| 943 | writeResult({ |
| 944 | cur, |
| 945 | sqlStatements, |
| 946 | journal, |
| 947 | _meta, |
| 948 | outFolder, |
| 949 | name: config.name, |
| 950 | breakpoints: config.breakpoints, |
| 951 | bundle: config.bundle, |
| 952 | prefixMode: config.prefix, |
| 953 | }); |
| 954 | } catch (e) { |
no test coverage detected