add-entity
Installation
SKILL.md
Add Database Entity
Create entity for $ARGUMENTS.
Steps
-
Read the pattern: Open
packages/server/api/src/app/tables/table/table.entity.tsas reference. -
Create entity file at
packages/server/api/src/app/{module}/{name}.entity.ts:- Use
EntitySchema(NOT decorators) - Include
...BaseColumnSchemaPart(id, created, updated) - Use
ApIdSchemafor foreign key columns ({ ...ApIdSchema, nullable: false }) - Add
projectIdcolumn + relation to project (CASCADE delete) - Add
foreignKeyConstraintNameon all join columns - Array columns:
{ type: String, array: true, nullable: false }
- Use
-
Register entity: Import and add to
getEntities()array inpackages/server/api/src/app/database/database-connection.ts. This is REQUIRED — TypeORM does NOT auto-discover.