1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 06:49:37 +02:00
AdventureLog/src/lib/db/schema.ts

50 lines
1.3 KiB
TypeScript

import {
pgTable,
text,
timestamp,
json,
serial,
varchar,
} from "drizzle-orm/pg-core";
export const featuredAdventures = pgTable("featuredAdventures", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
location: text("location"),
});
export const sharedAdventures = pgTable("sharedAdventures", {
id: text("id").primaryKey(),
data: json("data").notNull(),
});
export const userTable = pgTable("user", {
id: text("id").primaryKey(),
username: text("username").notNull(),
first_name: text("first_name").notNull(),
last_name: text("last_name").notNull(),
hashed_password: varchar("hashed_password").notNull(),
});
// export type SelectUser = typeof userTable.$inferSelect;
export const sessionTable = pgTable("session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => userTable.id),
expiresAt: timestamp("expires_at", {
withTimezone: true,
mode: "date",
}).notNull(),
});
export const userVisitedAdventures = pgTable("userVisitedAdventures", {
adventureID: serial("adventure_id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => userTable.id),
adventureName: text("adventure_name").notNull(),
location: text("location"),
visitedDate: text("visited_date"),
});