diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 46d7a34..7c8a603 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -11,6 +11,8 @@ export type { ProjectInsert, ProjectRecord, ProjectResponse, + SessionInsert, + SessionRecord, UserInsert, UserRecord, } from "./schema"; @@ -27,6 +29,9 @@ export { Project, ProjectInsertSchema, ProjectSelectSchema, + Session, + SessionInsertSchema, + SessionSelectSchema, User, UserInsertSchema, UserSelectSchema, diff --git a/packages/shared/src/schema.ts b/packages/shared/src/schema.ts index 2bbe7d3..c89dc9a 100644 --- a/packages/shared/src/schema.ts +++ b/packages/shared/src/schema.ts @@ -45,6 +45,16 @@ export const Project = pgTable("Project", { .references(() => User.id), }); +export const Session = pgTable("Session", { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer() + .notNull() + .references(() => User.id), + csrfToken: varchar({ length: 64 }).notNull(), + expiresAt: timestamp({ withTimezone: false }).notNull(), + createdAt: timestamp({ withTimezone: false }).defaultNow(), +}); + export const Issue = pgTable( "Issue", { @@ -86,6 +96,9 @@ export const ProjectInsertSchema = createInsertSchema(Project); export const IssueSelectSchema = createSelectSchema(Issue); export const IssueInsertSchema = createInsertSchema(Issue); +export const SessionSelectSchema = createSelectSchema(Session); +export const SessionInsertSchema = createInsertSchema(Session); + // Types export type UserRecord = z.infer; export type UserInsert = z.infer; @@ -102,6 +115,9 @@ export type ProjectInsert = z.infer; export type IssueRecord = z.infer; export type IssueInsert = z.infer; +export type SessionRecord = z.infer; +export type SessionInsert = z.infer; + // Responses export type IssueResponse = {