PHP 7.4.33
Preview: migrator.js Size: 1.77 KB
/var/www/gtechmarathon2026.bitkit.dk/httpdocs/node_modules/drizzle-orm/expo-sqlite/migrator.js
import { useEffect, useReducer } from "react";
async function readMigrationFiles({ journal, migrations }) {
  const migrationQueries = [];
  for await (const journalEntry of journal.entries) {
    const query = migrations[`m${journalEntry.idx.toString().padStart(4, "0")}`];
    if (!query) {
      throw new Error(`Missing migration: ${journalEntry.tag}`);
    }
    try {
      const result = query.split("--> statement-breakpoint").map((it) => {
        return it;
      });
      migrationQueries.push({
        sql: result,
        bps: journalEntry.breakpoints,
        folderMillis: journalEntry.when,
        hash: ""
      });
    } catch {
      throw new Error(`Failed to parse migration: ${journalEntry.tag}`);
    }
  }
  return migrationQueries;
}
async function migrate(db, config) {
  const migrations = await readMigrationFiles(config);
  return db.dialect.migrate(migrations, db.session);
}
const useMigrations = (db, migrations) => {
  const initialState = {
    success: false,
    error: void 0
  };
  const fetchReducer = (state2, action) => {
    switch (action.type) {
      case "migrating": {
        return { ...initialState };
      }
      case "migrated": {
        return { ...initialState, success: action.payload };
      }
      case "error": {
        return { ...initialState, error: action.payload };
      }
      default: {
        return state2;
      }
    }
  };
  const [state, dispatch] = useReducer(fetchReducer, initialState);
  useEffect(() => {
    dispatch({ type: "migrating" });
    migrate(db, migrations).then(() => {
      dispatch({ type: "migrated", payload: true });
    }).catch((error) => {
      dispatch({ type: "error", payload: error });
    });
  }, []);
  return state;
};
export {
  migrate,
  useMigrations
};
//# sourceMappingURL=migrator.js.map

Directory Contents

Dirs: 0 × Files: 30
Name Size Perms Modified Actions
2.33 KB lrw-r--r-- 2025-07-10 12:54:57
Edit Download
2.61 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
654 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
651 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
1.25 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.60 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
1.30 KB lrw-r--r-- 2025-07-10 12:54:57
Edit Download
271 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
90 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
87 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
120 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
225 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.82 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
4.10 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
806 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
805 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
1.77 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
4.06 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.91 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
2.98 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
418 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
416 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
1.58 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.98 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
5.52 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
8.89 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.95 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.95 KB lrw-r--r-- 2025-07-10 12:55:00
Edit Download
4.16 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
8.88 KB lrw-r--r-- 2025-07-10 12:55:00
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).