consolodate migrate schema

This commit is contained in:
JCEEE
2026-08-17 08:55:27 +01:00
parent fb18593ac5
commit 31fd9cce38
4 changed files with 139 additions and 2029 deletions
+16 -4
View File
@@ -1,9 +1,14 @@
// Single source of truth for the PocketBase schema + field builders.
// Consumed by BOTH proxy/src/migrate.ts (idempotent bootstrap) and
// proxy/scripts/seed.ts (fresh-store seed) so the schema isn't duplicated.
// Consumed by frontend/src/lib/server/migrate.ts (idempotent bootstrap) so the
// schema isn't duplicated.
//
// Relations reference collections by name; the `ids` map maps collection
// name -> runtime id (filled as each collection is created).
//
// NOTE: the native `users` auth collection and the superuser-only `otp`
// collection are NOT in SCHEMA_PLAN — they're applied separately in
// migrate.ts (users is PB's built-in auth model; `otp` needs null rules,
// which the `col()` builder can't express). Everything else lives here.
export interface FieldDef {
name: string;
@@ -128,7 +133,10 @@ export const SCHEMA_PLAN: CollectionPlanEntry[] = [
uniqueText("slug"),
text("stripeCustomerId"),
jsonField("featureFlags"),
jsonField("seasons"),
number("payday"),
text("lastIssued"),
text("paydayTime"),
text("timezone"),
],
{ listRule: RULE_OWN_FAM, viewRule: RULE_OWN_FAM, updateRule: RULE_OWN_FAM },
)(ids),
@@ -156,7 +164,7 @@ export const SCHEMA_PLAN: CollectionPlanEntry[] = [
{
name: "settings",
build: (ids) =>
col("settings", [rel("famId", ids.fams, true), text("webhookUrl")], {
col("settings", [rel("famId", ids.fams, true), text("webhookUrl"), bool("simulateEow")], {
createRule: RULE_PARENT_WRITE,
updateRule: RULE_PARENT_SCOPED,
deleteRule: RULE_PARENT_SCOPED,
@@ -246,6 +254,7 @@ export const SCHEMA_PLAN: CollectionPlanEntry[] = [
// Explicit createdAt: PB 0.39 does NOT auto-add createdAt to
// API-created collections (0.25 did). Chat filters/sorts on it.
date("createdAt"),
text("clientId"),
], {
createRule: RULE_FAM_WRITE,
updateRule: RULE_FAM_SCOPED,
@@ -302,6 +311,9 @@ export const SCHEMA_PLAN: CollectionPlanEntry[] = [
number("value", true),
text("customName"),
jsonField("seasonIds"),
bool("isTodo"),
text("startDate"),
text("completeBy"),
], {
createRule: RULE_PARENT_WRITE,
updateRule: RULE_PARENT_SCOPED,