From 7bf0984698e43b9aa2dd879f65951318ed410390 Mon Sep 17 00:00:00 2001 From: Maze <167211895+mazeincoding@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:20:04 +0100 Subject: codebase overhaul (#697) --- packages/db/src/index.ts | 38 ------------------------- packages/db/src/keys.ts | 19 ------------- packages/db/src/schema.ts | 70 ----------------------------------------------- 3 files changed, 127 deletions(-) delete mode 100644 packages/db/src/index.ts delete mode 100644 packages/db/src/keys.ts delete mode 100644 packages/db/src/schema.ts (limited to 'packages/db/src') diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts deleted file mode 100644 index 9b395ab6..00000000 --- a/packages/db/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { drizzle } from "drizzle-orm/postgres-js"; -import postgres from "postgres"; -import * as schema from "./schema"; -import { keys } from "./keys"; - -const { DATABASE_URL } = keys(); -// Create a lazy database instance that only initializes when accessed -let _db: ReturnType | null = null; - -function getDb() { - if (!_db) { - const client = postgres(DATABASE_URL); - _db = drizzle(client, { schema }); - } - - return _db; -} - -// Export a proxy that forwards all calls to the actual db instance -export const db = getDb(); - -// Re-export schema for convenience -export * from "./schema"; - -// Re-export drizzle-orm functions to ensure version consistency -export { - eq, - and, - or, - not, - isNull, - isNotNull, - inArray, - notInArray, - exists, - notExists, - sql, -} from "drizzle-orm"; diff --git a/packages/db/src/keys.ts b/packages/db/src/keys.ts deleted file mode 100644 index 65983416..00000000 --- a/packages/db/src/keys.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createEnv } from "@t3-oss/env-nextjs"; -import { z } from "zod"; - -export const keys = () => - createEnv({ - server: { - NODE_ENV: z - .enum(["development", "production", "test"]) - .default("development"), - DATABASE_URL: z - .string() - .startsWith("postgres://") - .or(z.string().startsWith("postgresql://")), - }, - runtimeEnv: { - NODE_ENV: process.env.NODE_ENV, - DATABASE_URL: process.env.DATABASE_URL, - }, - }); diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts deleted file mode 100644 index a1a69e6d..00000000 --- a/packages/db/src/schema.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core"; - -export const users = pgTable("users", { - id: text("id").primaryKey(), - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified").default(false).notNull(), - image: text("image"), - createdAt: timestamp("created_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), - updatedAt: timestamp("updated_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), -}).enableRLS(); - -export const sessions = pgTable("sessions", { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") - .notNull() - .references(() => users.id, { onDelete: "cascade" }), -}).enableRLS(); - -export const accounts = pgTable("accounts", { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") - .notNull() - .references(() => users.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), -}).enableRLS(); - -export const verifications = pgTable("verifications", { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").$defaultFn( - () => /* @__PURE__ */ new Date() - ), - updatedAt: timestamp("updated_at").$defaultFn( - () => /* @__PURE__ */ new Date() - ), -}).enableRLS(); - -export const exportWaitlist = pgTable("export_waitlist", { - id: text("id").primaryKey(), - email: text("email").notNull().unique(), - createdAt: timestamp("created_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), - updatedAt: timestamp("updated_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), -}).enableRLS(); -- cgit v1.3.1