Supabase: Schema, RLS-Policies und Seed-Daten

This commit is contained in:
2026-07-17 18:18:10 +02:00
parent d11d2a0687
commit 63a30a3835
3 changed files with 363 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
// Führt eine SQL-Datei gegen das Supabase-Projekt aus (Management API).
// Aufruf: SUPABASE_ACCESS_TOKEN=... node scripts/db-apply.mjs <pfad-zur-sql-datei>
import { readFileSync } from "node:fs";
const PROJECT_REF = "hvzikwjoyhoakedlywhj";
const token = process.env.SUPABASE_ACCESS_TOKEN;
const file = process.argv[2];
if (!token || !file) {
console.error("Nutzung: SUPABASE_ACCESS_TOKEN=... node scripts/db-apply.mjs <datei.sql>");
process.exit(1);
}
const query = readFileSync(file, "utf8");
const res = await fetch(
`https://api.supabase.com/v1/projects/${PROJECT_REF}/database/query`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ query }),
}
);
const body = await res.text();
if (!res.ok) {
console.error(`Fehler ${res.status}: ${body}`);
process.exit(1);
}
console.log("OK:", body.slice(0, 500));