Supabase: Schema, RLS-Policies und Seed-Daten
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user