import { boolean, integer, pgTable, primaryKey, timestamp, varchar } from "drizzle-orm/pg-core"; export const users = pgTable("users", { id: integer().primaryKey().generatedAlwaysAsIdentity(), email: varchar().unique().notNull(), //! make this required on signup name: varchar({ length: 26 }).unique().notNull(), pass: varchar({ length: 255 }).notNull(), registered: timestamp().notNull(), moderator: boolean().default(false).notNull(), banned: boolean().default(false).notNull() //! Not actually functional, banned users can still login }); export const updates = pgTable("updates", { id: integer().primaryKey().generatedAlwaysAsIdentity(), user: integer() .references(() => users.id, { onDelete: "cascade" }) .notNull(), mood: integer().default(0).notNull(), description: varchar({ length: 512 }).default("").notNull(), date: timestamp().notNull() }); export const journalEntries = pgTable("journal_entries", { id: integer().primaryKey().generatedAlwaysAsIdentity(), user: integer().references(() => users.id, { onDelete: "cascade" }).notNull(), moodChange: integer("mood-change").default(0).notNull(), entry: varchar({ length: 4096 }).default("").notNull(), visibility: integer().default(1).notNull(), date: timestamp().notNull() }); export const profiles = pgTable("profiles", { user: integer() .references(() => users.id, { onDelete: "cascade" }) .primaryKey() .notNull(), bio: varchar({ length: 1024 }).default("").notNull(), website: varchar().default("").notNull() }); export const follows = pgTable( "follows", { userId: integer("user_id").references(() => users.id, { onDelete: "cascade" }), followerId: integer("follower_id").references(() => users.id, { onDelete: "cascade" }) }, (table) => { return { pk: primaryKey({ columns: [table.userId, table.followerId] }) }; } );