feat(seed): production per-account PSA demo, gated to production (PMS-710) #485
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-710-per-account-psa-seed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PMS-710: Redefine seed data per environment
Production seeds a small, coherent set of Mokosh PSA examples for each new account; staging (and every non-production environment) seeds nothing automatically.
Trace (acceptance criterion 1)
Three seed systems exist. Only mokosh-server's per-account
SeedServiceis the "new account" seed; the others are out of scope.seed.rs- the admin "Demo MSP"/"minimal" templates seed PLATFORM entities (users/apps/groups/feedback) under the reserved email domaindemo.psa-systems.test. That reserved domain is a bunyip reset-scope key (PSA-56), not a mokosh concept, and is unrelated to per-account PSA seeding. (The Demo MSP button defect is PMS-709, already fixed and separate.)SeedService(PMS-157) - the first-visit per-account auto-seed. Before this change: one company, two contacts, three tickets, taggeddemo, data-driven fromdemo_seed.json. Also backs the Settings -> Data "Load demo data" button (PMS-679).showcase/qa- operator/CLI-only rich datasets that explicitly refuse production tenants. Out of scope.Environment / tenant facts that shaped the design:
MOKOSH_DEMO_SEED: "false", so the per-account seed was OFF in both. Production seeded nothing either.ensure_personal_tenant, which runscopy_default_config), and users stuck in the shared default get backfilled off it. So per-account scoping is already the model - the auto-seed scopes to the visiting personal tenant. No shared demo domain is involved on the mokosh side.Change (mokosh-server code + tests)
demo_seed.json+data.rs): widened to two companies, four contacts, one service SLA (attached to a client viacompany.sla_id), two projects (one active with a phase and a task), and five tickets - enough that company -> contact -> ticket -> project -> SLA relationships are visible, and no more. Human content stays in the JSON; FK wiring and structural fields live in the builders.SeedServicedrives the projects and SLA services too, in FK order; the project phase/task and each ticket are best-effort so a tenant missing default config still gets the core rows. Ticketsla_idis intentionally left to the SLA subsystem; the durable "client is on an SLA" relationship iscompany.sla_id.service.rs): the automatic first-visit seed runs inENVIRONMENT=productiononly; every other environment seeds nothing unless a developer setsMOKOSH_DEMO_SEED=true. The decision is a pure, unit-testedseed_enabled_for(environment, override)captured once into a per-instanceenabledflag (with_seed_enabledfor tests). The explicit "Load demo data" admin action is unchanged and not gated.data.rsbundle-shape unit test;service.rsgate unit tests (production seeds, staging/dev do not, dev honours the opt-in);tests/seed_demo.rsupdated to the new profile with a company -> SLA relationship assertion, plus a newauto_seed_is_a_no_op_when_the_gate_is_offproving staging seeds nothing.Verification
cargo fmt --check,clippy --all-targets -D warnings, lib + doc tests, and theseed_demoPostgres suite (8 tests) all pass. Full integration suite is green except three pre-existing upload/attachment tests that fail only in my sandbox withPermission denied (os error 13)writing files to disk - a filesystem-permission artifact unrelated to this change (it touches no storage code). Not yet run against live staging.Acceptance status
auto_seed_is_a_no_op_when_the_gate_is_off).Deferred by agreement (scoped to mokosh-server code this pass):
ENVIRONMENT=production, so the staleMOKOSH_DEMO_SEED: "false"in nc-01 is now a no-op). Cleaning that stale line from nc-01/c-01 is optional hygiene.