mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-15 22:38:47 +00:00
사용자 관련 DB 스키마 생성
This commit is contained in:
29
src/lib/server/db/schema/device.ts
Normal file
29
src/lib/server/db/schema/device.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { sqliteTable, text, integer, primaryKey } from "drizzle-orm/sqlite-core";
|
||||
import { user } from "./user";
|
||||
|
||||
export enum UserDeviceState {
|
||||
PENDING = 0,
|
||||
ACTIVE = 1,
|
||||
}
|
||||
|
||||
export const device = sqliteTable("device", {
|
||||
id: integer("id").primaryKey(),
|
||||
pubKey: text("pub_key").notNull().unique(),
|
||||
});
|
||||
|
||||
export const userDevice = sqliteTable(
|
||||
"user_device",
|
||||
{
|
||||
userId: integer("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
deviceId: integer("device_id")
|
||||
.notNull()
|
||||
.references(() => device.id),
|
||||
state: integer("state").notNull().default(0),
|
||||
encKey: text("enc_key"),
|
||||
},
|
||||
(t) => ({
|
||||
pk: primaryKey({ columns: [t.userId, t.deviceId] }),
|
||||
}),
|
||||
);
|
||||
2
src/lib/server/db/schema/index.ts
Normal file
2
src/lib/server/db/schema/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./device";
|
||||
export * from "./user";
|
||||
@@ -2,5 +2,6 @@ import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const user = sqliteTable("user", {
|
||||
id: integer("id").primaryKey(),
|
||||
age: integer("age"),
|
||||
email: text("email").notNull().unique(),
|
||||
password: text("password").notNull(),
|
||||
});
|
||||
@@ -14,7 +14,7 @@
|
||||
<p>서비스를 이용하려면 로그인을 해야해요.</p>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-col gap-y-2">
|
||||
<TextInput placeholder="아이디" />
|
||||
<TextInput placeholder="이메일" />
|
||||
<TextInput placeholder="비밀번호" type="password" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user