Files
klz-cables.com/.pnpm-store/v10/files/16/c2521bbe208fc5d42af19a8a55b684e4c52a798a080d2f6b71b38804124a316e13bfc1f1c9c6ce17e60bd6c105e993ec02527fb10ed01027af8d439f0aa88b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

32 lines
1.2 KiB
Plaintext

import { readMigrationFiles } from "../migrator.js";
import { sql } from "../sql/sql.js";
async function migrate(db, callback, config) {
const migrations = readMigrationFiles(config);
const migrationsTable = typeof config === "string" ? "__drizzle_migrations" : 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 numeric
)
`;
await db.run(migrationTableCreate);
const dbMigrations = await db.values(
sql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
const queriesToRun = [];
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
queriesToRun.push(
...migration.sql,
`INSERT INTO \`${migrationsTable}\` ("hash", "created_at") VALUES('${migration.hash}', '${migration.folderMillis}')`
);
}
}
await callback(queriesToRun);
}
export {
migrate
};
//# sourceMappingURL=migrator.js.map