Files
klz-cables.com/.pnpm-store/v10/files/76/7f791e1e9d65b3cf715a1788e7767663d5f6465d25d7c8986d4af8383c3973c24a01e0ddb4e7fce2364a1fcd742eb4bf8c84118e6d09394c0aeebd75801d34
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.1 KiB
Plaintext

import { readMigrationFiles } from "../migrator.js";
import { sql } from "../sql/sql.js";
async function migrate(db, 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.session.execute(migrationTableCreate);
const dbMigrations = await db.session.all(
sql`select id, hash, created_at from ${sql.identifier(migrationsTable)} order by created_at desc limit 1`
);
const lastDbMigration = dbMigrations[0];
for await (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration.created_at) < migration.folderMillis) {
for (const stmt of migration.sql) {
await db.session.execute(sql.raw(stmt));
}
await db.session.execute(
sql`insert into ${sql.identifier(migrationsTable)} ("hash", "created_at") values(${migration.hash}, ${migration.folderMillis})`
);
}
}
}
export {
migrate
};
//# sourceMappingURL=migrator.js.map