mirror of
https://github.com/getumbrel/umbrel-apps.git
synced 2026-11-21 13:34:26 +03:00
23 lines
691 B
JavaScript
23 lines
691 B
JavaScript
// https://pocketbase.io/docs/js-migrations/#creating-initial-superuser
|
|
// pb_migrations/1687801090_initial_superuser.js
|
|
|
|
migrate((app) => {
|
|
let superusers = app.findCollectionByNameOrId("_superusers")
|
|
|
|
let record = new Record(superusers)
|
|
|
|
// note: the values can be eventually loaded via $os.getenv(key)
|
|
// or from a special local config file
|
|
record.set("email", "umbrel@umbrel.local")
|
|
record.set("password", "umbrel-pocketbase")
|
|
|
|
app.save(record)
|
|
}, (app) => { // optional revert operation
|
|
try {
|
|
let record = app.findAuthRecordByEmail("_superusers", "umbrel@umbrel.local")
|
|
app.delete(record)
|
|
} catch {
|
|
// silent errors (probably already deleted)
|
|
}
|
|
})
|