Files
lettersoup-online/002_source/pocketbase/pb_migrations/00001_create_superuser.js
2025-04-18 03:06:06 +08:00

26 lines
617 B
JavaScript

// pb_migrations/0000000001_create_superuser.js
migrate(
(app) => {
const superusers_collection = app.findCollectionByNameOrId("_superusers");
const record = new Record(superusers_collection);
record.set("email", "[email protected]");
record.set("password", "Aa12345678");
app.save(record);
console.log("Superuser [email protected] created via migration");
},
(app) => {
try {
const record = app.findAuthRecordByEmail(
"_superusers",
"[email protected]"
);
app.delete(record);
} catch {
// silent errors (probably already deleted)
}
}
);