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

Function prepareAndMigrateLibSQL

drizzle-kit/src/cli/commands/migrate.ts:897–957  ·  view source on GitHub ↗
(config: GenerateConfig)

Source from the content-addressed store, hash-verified

895};
896
897export 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) {

Callers 1

schema.tsFile · 0.85

Calls 6

assertV1OutFolderFunction · 0.90
prepareMigrationFolderFunction · 0.90
squashSqliteSchemeFunction · 0.90
applyLibSQLSnapshotsDiffFunction · 0.90
writeResultFunction · 0.85

Tested by

no test coverage detected