/// // Remove the last of the 18+ scaffolding: the `nsfwEnabled` flag on `users`, the // rule clause that guarded it, and `adult` as a publishable release variant. // // WHY NOW: nothing reads the flag any more. `/api/amber/whoami` stopped // returning it, `GET /api/update/manifest` always serves `clean`, the `releases` // read rule stopped mentioning it in migration 1793000000 (the nine 18+ rows, // 437 MB, were deleted then), and the web settings page stopped showing an 18+ // source field in this same change. What was left was a per-account flag nobody // writes and nobody reads, sitting on the family's accounts and appearing in // every schema dump, README table and access-rule review as if it still gated // something. A flag that looks like a protection but protects nothing is worse // than no flag: the next person to read the schema has to prove it is dead. // // `users.updateRule` loses `@request.body.nsfwEnabled:isset = false`. The clause // was the structural guarantee that a signed-in person could not flip their own // flag. With the field gone there is nothing to flip, and PocketBase rejects an // unknown field on write anyway. `createRule` is already superuser-only (null, // migration 1789000000), so it needs no change. // // `releases.variant` KEEPS EXISTING and keeps being required -- only `adult` // leaves its allowed values. Every installed Amber compares the manifest's // variant against its own and refuses a mismatch **silently**, so removing the // field would strand every install with no error to see. Publishing stays // exactly as it is, minus a choice nobody can make any more. // // The down migration restores all three, so an instance can be rolled back. It // cannot restore the per-account VALUES of the flag: dropping a field drops its // data. That is intended -- the owner asked for the 18+ leftovers to be gone, // and the only account that had it set was a test account being retired with it. migrate( (app) => { const users = app.findCollectionByNameOrId("users") users.updateRule = "id = @request.auth.id" users.fields.removeByName("nsfwEnabled") app.save(users) const releases = app.findCollectionByNameOrId("releases") const variant = releases.fields.getByName("variant") variant.values = ["clean"] app.save(releases) }, (app) => { const users = app.findCollectionByNameOrId("users") users.fields.add(new BoolField({ name: "nsfwEnabled" })) users.updateRule = "id = @request.auth.id && @request.body.nsfwEnabled:isset = false" app.save(users) const releases = app.findCollectionByNameOrId("releases") const variant = releases.fields.getByName("variant") variant.values = ["clean", "adult"] app.save(releases) }, )