🎉 initial commit

This commit is contained in:
Robert Kunze
2026-01-12 17:44:56 +01:00
commit 7fb0512f65
8 changed files with 822 additions and 0 deletions

21
dbml.ts Normal file
View File

@@ -0,0 +1,21 @@
import getfiles from "https://deno.land/x/getfiles@v1.0.0/mod.ts";
import { exporter } from "npm:@dbml/core";
const schema_dir = "./db/";
export default function (args) {
const files = getfiles(schema_dir).filter((x) => x.name?.endsWith(".dbml"))
.sort((a, b) => a.name > b.name ? -1 : a.name == b.name ? 0 : 1);
Deno.mkdirSync("./db/migrations", { recursive: true });
for (const file of files) {
const dbml = Deno.readTextFileSync(schema_dir + file.name);
const sql = exporter.export(dbml, "postgres");
Deno.writeTextFileSync(
"./db/migrations/" +
new Date().toISOString() +
"_up_" + file.name.replace(/\.dbml$/, "") + ".sql",
sql,
);
}
}