# public.user_api_keys

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| id | varchar(36) |  | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |
| label | varchar(100) |  | false |  |  |  |
| apiKey | varchar |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| scopes | json |  | true |  |  |  |
| audience | varchar | 'public-api'::character varying | false |  |  |  |
| lastUsedAt | timestamp(3) with time zone |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| user_api_keys_apiKey_not_null | n | NOT NULL "apiKey" |
| user_api_keys_audience_not_null | n | NOT NULL audience |
| user_api_keys_createdAt_not_null | n | NOT NULL "createdAt" |
| user_api_keys_id_not_null | n | NOT NULL id |
| user_api_keys_label_not_null | n | NOT NULL label |
| user_api_keys_updatedAt_not_null | n | NOT NULL "updatedAt" |
| user_api_keys_userId_not_null | n | NOT NULL "userId" |
| FK_e131705cbbc8fb589889b02d457 | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_978fa5caa3468f463dac9d92e69 | PRIMARY KEY | PRIMARY KEY (id) |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_978fa5caa3468f463dac9d92e69 | CREATE UNIQUE INDEX "PK_978fa5caa3468f463dac9d92e69" ON public.user_api_keys USING btree (id) |
| IDX_63d7bbae72c767cf162d459fcc | CREATE UNIQUE INDEX "IDX_63d7bbae72c767cf162d459fcc" ON public.user_api_keys USING btree ("userId", label) |
| IDX_1ef35bac35d20bdae979d917a3 | CREATE UNIQUE INDEX "IDX_1ef35bac35d20bdae979d917a3" ON public.user_api_keys USING btree ("apiKey") |

## Relations

```mermaid
erDiagram

"public.user_api_keys" }o--|| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.user_api_keys" {
  varchar_36_ id
  uuid userId FK
  varchar_100_ label
  varchar apiKey
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone updatedAt
  json scopes
  varchar audience
  timestamp_3__with_time_zone lastUsedAt
}
"public.user" {
  uuid id
  varchar_255_ email
  varchar_32_ firstName
  varchar_32_ lastName
  varchar_255_ password
  json personalizationAnswers
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone updatedAt
  json settings
  boolean disabled
  boolean mfaEnabled
  text mfaSecret
  text mfaRecoveryCodes
  date lastActiveAt
  varchar_128_ roleSlug FK
}
```

---

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