Skip to content

Commit

Permalink
Docs: Clarify support for default database values (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper authored Sep 26, 2023
1 parent 1c38e3a commit c650df1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions documentation/content/main/basics/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ SDKs such as `@vercel/postgres` and `@neonserverless/database` provide drop-in r

## Database model

Lucia requires 3 tables to work, which are then connected to Lucia via a database adapter. This is only the basic model and the specifics depend on the adapter.

**The `id` columns are not UUID types with the default configuration.**
Lucia requires 3 tables to work, which are then connected to Lucia via a database adapter. This is only the basic model and the specifics depend on the adapter. **Lucia does not support default database values.**

### User table

The `id` column must be a string type, and as such, cannot be auto-incremented integer. It can be a UUID type, but keep in mind that the default user ids generated by Lucia are not UUIDs or ObjectIDs. You cannot use default (auto-generated) database values (such as UUIDs and ObjectIDs) and IDs must be generated at runtime.

| name | type | primary key | description |
| ---- | -------- | :---------: | ----------- |
| id | `string` || User id |
Expand All @@ -47,7 +47,7 @@ type UserSchema = {
} & Lucia.DatabaseUserAttributes;
```

In addition to the required fields shown below, you can add any additional fields to the table, in which case they should be declared in type `Lucia.DatabaseUserAttributes`.
In addition to the required fields shown below, you can add any additional fields to the table, in which case they should be declared in type `Lucia.DatabaseUserAttributes`. **Lucia does not support default (auto-generated) database values.**

```ts
declare namespace Lucia {
Expand All @@ -61,6 +61,8 @@ declare namespace Lucia {

### Session table

The `id` column must be a string type, and as such, cannot be auto-incremented integer. It can be a UUID type, but keep in mind that the default session ids generated by Lucia are not UUIDs or ObjectIDs. You cannot use default (auto-generated) database values (such as UUIDs and ObjectIDs) and IDs must be generated at runtime.

| name | type | primary key | references | description |
| -------------- | --------------- | :---------: | ---------- | -------------------------------------------------- |
| id | `string` || | |
Expand All @@ -77,7 +79,7 @@ type SessionSchema = {
} & Lucia.DatabaseSessionAttributes;
```

In addition to the required fields shown below, you can add any additional fields to the table, in which case they should be declared in type `Lucia.DatabaseSessionAttributes`.
In addition to the required fields shown below, you can add any additional fields to the table, in which case they should be declared in type `Lucia.DatabaseSessionAttributes`. **Lucia does not support default (auto-generated) database values.**

```ts
declare namespace Lucia {
Expand All @@ -91,6 +93,8 @@ declare namespace Lucia {

### Key table

The `id` column must be a regular string type. IDs are generated by Lucia and cannot be configured. It cannot be an auto-incremented integer, UUID, or ObjectID, nor could it be auto-generated by the database.

| name | type | primary key | references | description |
| --------------- | ---------------- | :---------: | ---------- | -------------------------------------------------------- |
| id | `string` || | Key id in the form of: `${providerId}:${providerUserId}` |
Expand Down

0 comments on commit c650df1

Please sign in to comment.