BREAKING CHANGE: migrations are deployed separately
Some checks failed
ci/woodpecker/push/woodpecker/1 Pipeline failed
ci/woodpecker/push/woodpecker/3 Pipeline was successful
ci/woodpecker/push/woodpecker/2 Pipeline was successful

This commit is contained in:
f 2023-12-12 11:06:35 -03:00
parent 9bf29b20dc
commit 45674db0b5
No known key found for this signature in database

View file

@ -1,28 +0,0 @@
// https://pocketbase.io/docs/js-migrations/#creating-new-admin
const email = "pocketbase@sutty.nl";
migrate(
(db) => {
const dao = new Dao(db);
const adminPwEnv = $os.getenv("ADMIN_PASSWORD");
if (adminPwEnv) {
const admin = new Admin();
admin.email = email;
admin.setPassword(adminPwEnv);
dao.saveAdmin(admin);
}
},
(db) => {
// optional revert
const dao = new Dao(db);
try {
const admin = dao.findAdminByEmail(email);
dao.deleteAdmin(admin);
} catch (_) {
/* most likely already deleted */
}
},
);