27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
// Isolated Postgres verification. Install the optional test runtime with:
|
|
// npm install --prefix .data/sql-verification --no-save --package-lock=false @electric-sql/pglite@0.3.14
|
|
import { readFile, readdir } from "node:fs/promises";
|
|
import { PGlite } from "../.data/sql-verification/node_modules/@electric-sql/pglite/dist/index.js";
|
|
const db = new PGlite();
|
|
try {
|
|
await db.exec(`create role anon; create role authenticated; create role service_role;
|
|
create schema auth; create table auth.users(id uuid primary key);
|
|
create function auth.uid() returns uuid language sql as $$ select null::uuid $$;
|
|
create schema storage; create table storage.buckets(id text primary key,name text,public boolean,file_size_limit bigint);`);
|
|
for (const file of (await readdir("supabase/migrations"))
|
|
.filter((f) => f.endsWith(".sql"))
|
|
.sort()) {
|
|
await db.exec(await readFile(`supabase/migrations/${file}`, "utf8"));
|
|
console.log(`Migration passed: ${file}`);
|
|
}
|
|
await db.exec(await readFile("tests/sql/moderation.sql", "utf8"));
|
|
console.log(
|
|
"Moderation SQL passed: reporting, authorization, duplicate handling, strikes, bans, appeals, and history.",
|
|
);
|
|
} catch (error) {
|
|
console.error(error.message);
|
|
process.exitCode = 1;
|
|
} finally {
|
|
await db.close();
|
|
}
|