# public.instance_ai_messages

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| content | text |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| resourceId | varchar(255) |  | true |  |  |  |
| role | varchar(16) |  | false |  |  |  |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| type | varchar(32) |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1eeb64cb9d66a927988de759e6e | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_156c6f287225e9befe0181bb02b | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_messages_content_not_null | n | NOT NULL content |
| instance_ai_messages_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_messages_id_not_null | n | NOT NULL id |
| instance_ai_messages_role_not_null | n | NOT NULL role |
| instance_ai_messages_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_messages_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_1eeb64cb9d66a927988de759e6 | CREATE INDEX "IDX_1eeb64cb9d66a927988de759e6" ON public.instance_ai_messages USING btree ("threadId") |
| IDX_76e212c6867fbaa06bf0decd6f | CREATE INDEX "IDX_76e212c6867fbaa06bf0decd6f" ON public.instance_ai_messages USING btree ("resourceId") |
| PK_156c6f287225e9befe0181bb02b | CREATE UNIQUE INDEX "PK_156c6f287225e9befe0181bb02b" ON public.instance_ai_messages USING btree (id) |

## Relations

```mermaid
erDiagram

"public.instance_ai_messages" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_messages" {
  text content
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_255_ resourceId
  varchar_16_ role
  uuid threadId FK
  varchar_32_ type
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)
