consolodate migrate schema
This commit is contained in:
+16
-4
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user