// `migrations/assets.ts` inlines the .sql migrations as base64 so they survive // publishing. It used to be regenerated by hand, and drifted: the bundled // system-up-v-0.0.0 still carried a `CREATE EXTENSION pg_ivm` long after it was // deleted from the .sql file, which broke the ALLOW_NO_PG_IVM fallback on real // Postgres. Regenerate with `bun run assets:generate` from the repo root. import { test, expect } from "bun:test"; import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import bundle from "../migrations/assets.ts"; const PACKAGE_ROOT = resolve(import.meta.dir, ".."); const config: { files: { importPath: string; calledName: string }[] } = JSON.parse(readFileSync(resolve(PACKAGE_ROOT, "assets-config.json"), "utf8")); test("every configured migration is present in the bundle", () => { expect(Object.keys(bundle.files).sort()).toEqual( config.files.map((f) => f.calledName).sort(), ); }); for (const file of config.files) { test(`bundled ${file.calledName} matches ${file.importPath}`, () => { const source = readFileSync(resolve(PACKAGE_ROOT, file.importPath), "utf8"); const bundled = new TextDecoder().decode( bundle.files[file.calledName as keyof typeof bundle.files].content, ); expect(bundled).toBe(source); }); }