返回 Skill 列表
extension
分类: 开发与工程无需 API Key

yii2-model-to-prisma

将Yii2 ActiveRecord模型转换为Prisma Schema定义。

person作者: jakexiaohubgithub

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 by tableName().

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 @unique attribute.
  • default -> Add @default(value).

4. Relationships

  • hasOne: profile Profile?
  • hasMany: posts Post[]

See examples.md for detailed transformation scenarios.