40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
|
|
/// <reference path="../pb_data/types.d.ts" />
|
||
|
|
|
||
|
|
// Add `ratingDefault` to users: the account-wide content ceiling.
|
||
|
|
//
|
||
|
|
// WHY IT MOVES TO THE SERVER: the per-profile override (`profiles.maxRating`)
|
||
|
|
// has lived here since migration 1787000000, while the *account default* it falls
|
||
|
|
// back to stayed in each device's secure storage. So the same parental control was
|
||
|
|
// half synced and half not — set the default on the PC and the television still
|
||
|
|
// used whatever it had. It is also the one of the four device-local settings the
|
||
|
|
// owner asked to sync, precisely because it is a parental control rather than a
|
||
|
|
// per-device convenience (`adult_enabled` deliberately does NOT follow: a toggle
|
||
|
|
// propagating to the children's television is a safety change, not a nicety).
|
||
|
|
//
|
||
|
|
// Stores the RatingTier enum name — `kids` | `twelve` | `fifteen` |
|
||
|
|
// `unrestricted` — matching `RatingTier.fromName`/`.name` in the app, so the
|
||
|
|
// existing device-local value migrates by being pushed as-is.
|
||
|
|
//
|
||
|
|
// Nullable: every account predates this, and an absent value must read as "not
|
||
|
|
// set" so `RatingTier.unrestricted` remains the fallback rather than a null crash.
|
||
|
|
// The app's two-clock LWW decides who wins when a device and the server disagree.
|
||
|
|
|
||
|
|
migrate(
|
||
|
|
(app) => {
|
||
|
|
const users = app.findCollectionByNameOrId("users")
|
||
|
|
users.fields.add(
|
||
|
|
new TextField({
|
||
|
|
name: "ratingDefault",
|
||
|
|
required: false,
|
||
|
|
max: 20,
|
||
|
|
}),
|
||
|
|
)
|
||
|
|
app.save(users)
|
||
|
|
},
|
||
|
|
(app) => {
|
||
|
|
const users = app.findCollectionByNameOrId("users")
|
||
|
|
users.fields.removeByName("ratingDefault")
|
||
|
|
app.save(users)
|
||
|
|
},
|
||
|
|
)
|