kanban-dev-webapp/scripts/apply-work-area-schema.ts

21 lines
745 B
TypeScript
Raw Normal View History

import PocketBase from "pocketbase";
import { ensureWorkAreaSchema } from "./work-area-schema";
async function main() {
const url = process.env.NEXT_PUBLIC_PB_URL;
const email = process.env.PB_SUPERUSER_EMAIL;
const password = process.env.PB_SUPERUSER_PASSWORD;
if (!url || !email || !password) throw new Error("PocketBase URL and superuser credentials are required");
const pb = new PocketBase(url);
pb.autoCancellation(false);
await pb.collection("_superusers").authWithPassword(email, password);
const changed = await ensureWorkAreaSchema(pb);
console.log(changed.length ? `Added ${changed.join(", ")}` : "Work area schema already exists");
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});