38 lines
No EOL
1 KiB
JavaScript
38 lines
No EOL
1 KiB
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
/**
|
|
* `active` on users.
|
|
*
|
|
* REFERENCE ONLY — see pb_migrations/README.md. scripts/setup-remote.ts is
|
|
* what runs.
|
|
*
|
|
* Accounts are deactivated, never deleted: activity.actor and comments.author
|
|
* are relations to users, and removing a row turns every historical entry that
|
|
* referenced it into "Someone". An audit trail that forgets who did what is
|
|
* not an audit trail.
|
|
*
|
|
* Existing rows are backfilled to true so nobody is locked out by the upgrade.
|
|
*/
|
|
migrate(
|
|
(app) => {
|
|
const users = app.findCollectionByNameOrId("users");
|
|
|
|
users.fields.add(
|
|
new Field({ name: "active", type: "bool", required: false })
|
|
);
|
|
|
|
app.save(users);
|
|
|
|
for (const user of app.findAllRecords("users")) {
|
|
user.set("active", true);
|
|
app.save(user);
|
|
}
|
|
|
|
return true;
|
|
},
|
|
(app) => {
|
|
const users = app.findCollectionByNameOrId("users");
|
|
const field = users.fields.find((f) => f.name === "active");
|
|
if (field) users.fields.removeById(field.id);
|
|
return app.save(users);
|
|
}
|
|
); |