This commit is contained in:
parent
e71702d358
commit
48c956dae4
@ -20,7 +20,9 @@ export async function createSession(token: string, userId: string) {
|
||||
const session: table.Session = {
|
||||
id: sessionId,
|
||||
userId,
|
||||
expiresAt: new Date(Date.now() + DAY_IN_MS * 30)
|
||||
expiresAt: new Date(Date.now() + DAY_IN_MS * 30),
|
||||
createdAt: new Date(Date.now()),
|
||||
updatedAt: new Date(Date.now()),
|
||||
};
|
||||
await db.insert(table.session).values(session);
|
||||
return session;
|
||||
|
||||
@ -2,17 +2,47 @@ import { pgTable, serial, integer, text, timestamp } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const user = pgTable('user', {
|
||||
id: text('id').primaryKey(),
|
||||
age: integer('age'),
|
||||
username: text('username').notNull().unique(),
|
||||
passwordHash: text('password_hash').notNull()
|
||||
age: integer('age'), //나이
|
||||
username: text('username').notNull().unique(), // username 이 사용자가 회원가입 할때 id 임
|
||||
nickname: text('nickname'), // 별칭
|
||||
helloword: text('helloword'), // 인사말, 소개말
|
||||
avatar: text('avatar'), // 아바타 파일경로
|
||||
email: text('email'), // 이메일주소
|
||||
gender: text('gender'), // 성별
|
||||
passwordHash: text('password_hash').notNull(),
|
||||
createdAt: timestamp(),
|
||||
updatedAt: timestamp(),
|
||||
});
|
||||
|
||||
export const session = pgTable('session', {
|
||||
id: text('id').primaryKey(),
|
||||
userId: text('user_id').notNull().references(() => user.id),
|
||||
expiresAt: timestamp('expires_at', { withTimezone: true, mode: 'date' }).notNull()
|
||||
expiresAt: timestamp('expires_at', { withTimezone: true, mode: 'date' }).notNull(),
|
||||
createdAt: timestamp(),
|
||||
updatedAt: timestamp(),
|
||||
});
|
||||
|
||||
export const post = pgTable('post', {
|
||||
id: text('id').primaryKey(),
|
||||
subject: text('subject'),
|
||||
slug: text('subject'),
|
||||
content: text('subject'),
|
||||
author: text('author'),
|
||||
status: text('status'), // draft, published 등등..
|
||||
category: text('category'),
|
||||
createdAt: timestamp(),
|
||||
updatedAt: timestamp(),
|
||||
});
|
||||
|
||||
export const hierarchy = pgTable('hierarchy', {
|
||||
id: text('id').primaryKey(),
|
||||
name: text('subject'),
|
||||
parent_id: text('subject'),
|
||||
createdAt: timestamp(),
|
||||
updatedAt: timestamp(),
|
||||
});
|
||||
|
||||
export type Session = typeof session.$inferSelect;
|
||||
|
||||
export type User = typeof user.$inferSelect;
|
||||
export type Post = typeof post.$inferSelect;
|
||||
export type Hierarchy = typeof hierarchy.$inferSelect;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user