---
description: >-
  This page shows some examples of possible usages for Prisma Util's Schema
  Creator module.
---

# Examples

### Creating a model with an auto-incrementing ID, then creating an enum with 2 elements

```javascript
import { SchemaCreator, Functions, Constraints } from "prisma-util/schema-creator";
SchemaCreator
    .model("Post")
        .column("id", "Int", Constraints.Column.ID(), Constraints.Column.DEFAULT(Functions.AUTOINCREMENT()))
        .column("title", "String", Constraints.Column.UNIQUE())
        .column("updatedAt", "DateTime", Constraints.Column.UPDATEDAT())
        .column("createdAt", "DateTime", Constraints.Column.DEFAULT(Functions.NOW()))
    .enum("Permissions")
        .item("READ")
        .item("WRITE");
```

### Creating a model with a relation

```javascript
import { SchemaCreator, Functions, Constraints } from "prisma-util/schema-creator";
SchemaCreator
    .model("Post")
        .column("id", "Int", Constraints.Column.ID(), Constraints.Column.DEFAULT(Functions.AUTOINCREMENT()))
        .column("title", "String", Constraints.Column.UNIQUE())
        .column("updatedAt", "DateTime", Constraints.Column.UPDATEDAT())
        .column("createdAt", "DateTime", Constraints.Column.DEFAULT(Functions.NOW()))
        .column("userId", "Int")
        .column("user", "User", Constraints.Column.RELATION({fields: ["userId"], references: ["id"]}))
```
