/** * Seed template — default rows, applied on EVERY application start for EVERY * tenant. Must be idempotent: matching runs on the entity's importKeyFields. * Rules: references/seeds.md. * * File name: __kebab-case-plural__.seed.ts. Register in forFeature({ seeds }) * AFTER the seeds it depends on (workflowsSeed before stageWorkflowsSeed). */ import { createSeed } from '@suppa/sdk'; import { __Field__Enum } from '../entities/__kebab-case-plural__.entity'; import { EntityNamesEnum } from '../../modules'; export const __camelCasePlural__Seed = createSeed(EntityNamesEnum.__EntityName__, [ { // ALWAYS include every importKeyField — else duplicate rows on restart. __businessKeyField__: 'Default', // Relation: reference by the TARGET's importKeyFields — NEVER numeric id. __target__: { name: 'Default' }, // Enum: { name: '', value: '' }. // NAMING AN ENUM HERE MAKES IT GLOBAL (SKILL.md rule 17): the entity's // @Enum must then pass that same name as its FIRST argument. If the enum // belongs to one field only, drop this line and let the field's value be // set by the user instead — do not name an enum the entity declares // locally. __field__: { name: '__EntityName__.__field__', value: __Field__Enum.Active, }, // NEVER include: id/createdAt/updatedAt/deletedAt/createdBy/removedBy, // $readAccess/$updateAccess/$instanceAccess, reverse @OneToMany fields // (even as []), numeric relation ids. }, { // Natural key doesn't fit? Override identity per record with $key: $key: { __businessKeyField__: 'unique-identity' }, __businessKeyField__: 'unique-identity', }, ]); /* Large payload? Keep the seed thin — move data to a static file: src/common/database/static/__name__.ts → export const ROWS = [ … ]; then: export const __name__Seed = createSeed('__EntityName__', ROWS); */