토큰에 클라이언트 정보를 함께 저장하도록 변경

This commit is contained in:
static
2024-12-26 17:04:52 +09:00
parent fac8764572
commit 45e214d49f
5 changed files with 57 additions and 23 deletions

View File

@@ -0,0 +1,29 @@
import { sqliteTable, text, integer, primaryKey } from "drizzle-orm/sqlite-core";
import { user } from "./user";
export enum UserClientState {
PENDING = 0,
ACTIVE = 1,
}
export const client = sqliteTable("client", {
id: integer("id").primaryKey(),
pubKey: text("public_key").notNull().unique(),
});
export const userClient = sqliteTable(
"user_client",
{
userId: integer("user_id")
.notNull()
.references(() => user.id),
clientId: integer("client_id")
.notNull()
.references(() => client.id),
state: integer("state").notNull().default(0),
encKey: text("encrypted_key"),
},
(t) => ({
pk: primaryKey({ columns: [t.userId, t.clientId] }),
}),
);