PHP 7.4.33
Preview: migrator.js Size: 1.20 KB
/var/www/gtechmarathon2026.bitkit.dk/httpdocs/node_modules/drizzle-orm/mysql-proxy/migrator.js
import { readMigrationFiles } from "../migrator.js";
import { sql } from "../sql/sql.js";
async function migrate(db, callback, config) {
  const migrations = readMigrationFiles(config);
  const migrationsTable = config.migrationsTable ?? "__drizzle_migrations";
  const migrationTableCreate = sql`
		create table if not exists ${sql.identifier(migrationsTable)} (
			id serial primary key,
			hash text not null,
			created_at bigint
		)
	`;
  await db.execute(migrationTableCreate);
  const dbMigrations = await db.select({
    id: sql.raw("id"),
    hash: sql.raw("hash"),
    created_at: sql.raw("created_at")
  }).from(sql.identifier(migrationsTable).getSQL()).orderBy(
    sql.raw("created_at desc")
  ).limit(1);
  const lastDbMigration = dbMigrations[0];
  const queriesToRun = [];
  for (const migration of migrations) {
    if (!lastDbMigration || Number(lastDbMigration.created_at) < migration.folderMillis) {
      queriesToRun.push(
        ...migration.sql,
        `insert into ${sql.identifier(migrationsTable).value} (\`hash\`, \`created_at\`) values('${migration.hash}', '${migration.folderMillis}')`
      );
    }
  }
  await callback(queriesToRun);
}
export {
  migrate
};
//# sourceMappingURL=migrator.js.map

Directory Contents

Dirs: 0 × Files: 24
Name Size Perms Modified Actions
2.29 KB lrw-r--r-- 2025-07-10 12:54:57
Edit Download
2.68 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
842 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
838 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
1.21 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.67 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
1.20 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
225 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
61 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
59 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
92 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
186 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.30 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
2.44 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
361 B lrw-r--r-- 2025-07-10 12:54:59
Edit Download
359 B lrw-r--r-- 2025-07-10 12:55:00
Edit Download
1.20 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
2.40 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
4.79 KB lrw-r--r-- 2025-07-10 12:54:58
Edit Download
8.35 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
3.38 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
3.37 KB lrw-r--r-- 2025-07-10 12:55:00
Edit Download
3.56 KB lrw-r--r-- 2025-07-10 12:54:59
Edit Download
8.32 KB lrw-r--r-- 2025-07-10 12:55:00
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).