Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/client/create-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { BetterAuthDBSchema, DBFieldAttribute } from "better-auth/db";
export const indexFields = {
account: ["accountId", ["accountId", "providerId"], ["providerId", "userId"]],
rateLimit: ["key"],
session: ["expiresAt", ["expiresAt", "userId"]],
session: ["expiresAt", ["expiresAt", "userId"], ["token", "expiresAt"]],
verification: ["expiresAt", "identifier"],
user: [["email", "name"], "name", "userId"],
oauthConsent: [["clientId", "userId"]],
Expand Down Expand Up @@ -129,8 +129,8 @@ export const tables = {
mergedIndexFields(tables)[
tableKey as keyof typeof mergedIndexFields
]?.map((index) => {
const indexArray = Array.isArray(index) ? index.sort() : [index];
const indexName = indexArray.join("_");
const indexArray = Array.isArray(index) ? index : [index];
const indexName = [...indexArray].sort().join("_");
return `.index("${indexName}", ${JSON.stringify(indexArray)})`;
}) || [];

Expand Down
1 change: 1 addition & 0 deletions src/component/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const tables = {
.index("expiresAt", ["expiresAt"])
.index("expiresAt_userId", ["expiresAt","userId"])
.index("token", ["token"])
.index("token_expiresAt", ["token","expiresAt"])
.index("userId", ["userId"]),
account: defineTable({
accountId: v.string(),
Expand Down