Yii2 Model to Prisma Schema Skill
This skill provides rules for transforming Yii2 PHP models (ActiveRecord) directly into Prisma model definitions (schema.prisma) for NestJS projects.
Transformation Rules
1. Model Definition
- Model Name: Use the class name in
PascalCase. - Table Mapping: Use
@@map("table_name")with the value returned bytableName().
2. Attributes and Data Types
| PHP / DB Type | Prisma Type | Notes |
| :--- | :--- | :--- |
| int, integer | Int | Add @id @default(autoincrement()) for PK. |
| string, varchar, text | String | |
| boolean, tinyint(1) | Boolean | |
| decimal, float | Decimal | |
| datetime, timestamp | DateTime | |
3. Constraints (from rules())
required-> Remove the?from the type (e.g.,String).unique-> Add the@uniqueattribute.default-> Add@default(value).
4. Relationships
- hasOne:
profile Profile? - hasMany:
posts Post[]
See examples.md for detailed transformation scenarios.
微信扫一扫