26 lines
617 B
JavaScript
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)
|
|
}
|
|
}
|
|
);
|