Files
MineGeo/scripts/test-map-admins-sql.mjs
pavel444-byte 05854818a0
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m2s
Map admins: owners invite friends to co-manage maps
Owners can invite players by name from the map workshop; invitees accept
from their dashboard and then manage the map (details, locations,
submission, refresh, contributions, appeals) through owner-delegated
checks. Adds the map_admins table, invite/admin API endpoints, dashboard
invite box, workshop admin management, and Russian translations.
2026-10-31 17:28:05 +05:00

26 lines
1.3 KiB
JavaScript

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,allowed_mime_types text[]);
create table storage.objects(id uuid primary key default gen_random_uuid(),bucket_id text,name text);
create function storage.foldername(name text) returns text[] language sql as $$ select string_to_array(name, '/') $$;`);
for (const file of (await readdir("supabase/migrations"))
.filter((f) => f.endsWith(".sql"))
.sort())
await db.exec(await readFile(`supabase/migrations/${file}`, "utf8"));
await db.exec(await readFile("tests/sql/map-admins.sql", "utf8"));
console.log(
"Map admins SQL passed: invites start pending, duplicates/self-invites blocked, accept stamps the response, deletion cascades.",
);
} catch (error) {
console.error(error.message, error.where ?? "");
process.exitCode = 1;
} finally {
await db.close();
}