Files
klz-cables.com/.pnpm-store/v10/files/f5/aa7ef0c6fd8f0b6f4e4de999b208b1fb2141b2a8caae953b80eedb8daf767fe5fbc9c4a10042487340608249bb8806ac3af8a868021eceb6134620ce93c383
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

36 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 = 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